The larger point is, we shouldn't throw an uninformative NPE.

git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@208 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
Ray Greenwell
2007-02-24 00:13:22 +00:00
parent 200042c87e
commit f19a973e27
+17 -3
View File
@@ -165,9 +165,7 @@ public class EZGameControl extends BaseControl
*/
public function get (propName :String, index :int = -1) :Object
{
if (_gameData == null) {
return null;
}
checkIsConnected();
var value :Object = _gameData[propName];
if (index >= 0) {
@@ -572,6 +570,10 @@ public class EZGameControl extends BaseControl
} catch (err :Error) {
trace("Unable to call ez code: " + err);
}
} else {
// if _funcs is null, this will almost certainly throw an error..
checkIsConnected();
}
}
@@ -585,6 +587,18 @@ public class EZGameControl extends BaseControl
callEZCode.apply(this, args);
}
/**
* Throw an error if we're not connected.
*/
protected function checkIsConnected () :void
{
if (!isConnected()) {
throw new IllegalOperationError("The game is not connected " +
"to The Whirled, please check isConnected(). If false, your " +
"game is being viewed standalone and should adjust.");
}
}
/**
* Internal method that is called whenever the mouse clicks our root.
*/