X-Git-Url: https://git.mxchange.org/?p=shipsimu.git;a=blobdiff_plain;f=application%2Fship-simu%2Fmain%2Fuser%2Fclass_ShipSimuBaseUser.php;fp=application%2Fship-simu%2Fmain%2Fuser%2Fclass_ShipSimuBaseUser.php;h=ffc4c6edc7eefd59f8082ccbe98f158f4a4590ed;hp=426edcbedceceb92fd398a835a3c173626e1209e;hb=914dfa3693b96e822e5d60adae52be561cab8412;hpb=0846b33552201b7a3b9d7e3debf83e7d073baaa3 diff --git a/application/ship-simu/main/user/class_ShipSimuBaseUser.php b/application/ship-simu/main/user/class_ShipSimuBaseUser.php index 426edcb..ffc4c6e 100644 --- a/application/ship-simu/main/user/class_ShipSimuBaseUser.php +++ b/application/ship-simu/main/user/class_ShipSimuBaseUser.php @@ -106,8 +106,16 @@ class ShipSimuBaseUser extends BaseUser implements Registerable, Updateable { // By default they want to help. $ifGovHelps = true; - // First get a government instance from registry - $governmentInstance = Registry::getRegistry()->getInstance('government'); + // Init instance + $governmentInstance = null; + + try { + // First get a government instance from registry + $governmentInstance = Registry::getRegistry()->getInstance('government'); + } catch (NullPointerException $e) { + // Instance not found in registry + // @TODO We should log this exception later + } // Is it there? if (is_null($governmentInstance)) { @@ -137,8 +145,16 @@ class ShipSimuBaseUser extends BaseUser implements Registerable, Updateable { // By default they want to help. $ifGovHelps = true; - // First get a government instance from registry - $governmentInstance = Registry::getRegistry()->getInstance('government'); + // Init instance + $governmentInstance = null; + + try { + // First get a government instance from registry + $governmentInstance = Registry::getRegistry()->getInstance('government'); + } catch (NullPointerException $e) { + // Instance not found in registry + // @TODO We should log this exception later + } // Is it there? if (is_null($governmentInstance)) { @@ -169,8 +185,16 @@ class ShipSimuBaseUser extends BaseUser implements Registerable, Updateable { // Per default the money bank cannot pay $bankLends = false; - // Get a money bank instance from registry - $bankInstance = Registry::getRegistry()->getInstance('money_bank'); + // Init instance + $bankInstance = null; + + try { + // Get a money bank instance from registry + $bankInstance = Registry::getRegistry()->getInstance('money_bank'); + } catch (NullPointerException $e) { + // Instance not found in registry + // @TODO We should log this exception later + } // Is it there? if (is_null($bankInstance)) { @@ -205,8 +229,16 @@ class ShipSimuBaseUser extends BaseUser implements Registerable, Updateable { // For default he can still get money $hasMaxCredits = false; - // Get a money bank instance from registry - $bankInstance = Registry::getRegistry()->getInstance('money_bank'); + // Init instance + $bankInstance = null; + + try { + // Get a money bank instance from registry + $bankInstance = Registry::getRegistry()->getInstance('money_bank'); + } catch (NullPointerException $e) { + // Instance not found in registry + // @TODO We should log this exception later + } // Is it there? if (is_null($bankInstance)) {