From f19a973e279255ddba79f54cdfb42d1fa13641b9 Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Sat, 24 Feb 2007 00:13:22 +0000 Subject: [PATCH] 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 --- src/as/com/threerings/ezgame/EZGameControl.as | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/as/com/threerings/ezgame/EZGameControl.as b/src/as/com/threerings/ezgame/EZGameControl.as index f225c142..826eeb70 100644 --- a/src/as/com/threerings/ezgame/EZGameControl.as +++ b/src/as/com/threerings/ezgame/EZGameControl.as @@ -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. */