found new exception

This commit is contained in:
kremsy 2015-06-18 16:18:19 +02:00
parent fc7b1bdade
commit cf0555f422
2 changed files with 57 additions and 24 deletions

View File

@ -4,6 +4,7 @@ namespace ManiaControl\Server;
use ManiaControl\Logger; use ManiaControl\Logger;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
use Maniaplanet\DedicatedServer\Xmlrpc\GameModeException;
/** /**
* Manager for Game Mode Script related Stuff * Manager for Game Mode Script related Stuff
@ -39,7 +40,12 @@ class ScriptManager {
if (!$this->isScriptMode()) { if (!$this->isScriptMode()) {
return false; return false;
} }
try {
$scriptSettings = $this->maniaControl->getClient()->getModeScriptSettings(); $scriptSettings = $this->maniaControl->getClient()->getModeScriptSettings();
} catch (GameModeException $e) {
return false;
}
if (!array_key_exists('S_UseScriptCallbacks', $scriptSettings)) { if (!array_key_exists('S_UseScriptCallbacks', $scriptSettings)) {
return false; return false;

View File

@ -7,12 +7,9 @@
namespace Maniaplanet\DedicatedServer\Xmlrpc; namespace Maniaplanet\DedicatedServer\Xmlrpc;
class FaultException extends Exception class FaultException extends Exception {
{ static function create($faultString, $faultCode) {
static function create($faultString, $faultCode) switch ($faultString) {
{
switch($faultString)
{
case 'Password incorrect.': case 'Password incorrect.':
case 'Permission denied.': case 'Permission denied.':
return new AuthenticationException($faultString, $faultCode); return new AuthenticationException($faultString, $faultCode);
@ -81,6 +78,7 @@ class FaultException extends Exception
case 'Not in Team mode.': case 'Not in Team mode.':
case 'Not in Rounds or Laps mode.': case 'Not in Rounds or Laps mode.':
case 'The scores must be decreasing.': case 'The scores must be decreasing.':
case 'No current script.':
return new GameModeException($faultString, $faultCode); return new GameModeException($faultString, $faultCode);
case 'Unable to write the black list file.': case 'Unable to write the black list file.':
case 'Unable to write the guest list file.': case 'Unable to write the guest list file.':
@ -92,26 +90,55 @@ class FaultException extends Exception
case 'Invalid url.': case 'Invalid url.':
return new FileException($faultString, $faultCode); return new FileException($faultString, $faultCode);
} }
if(preg_match('~^Unknown setting \'.*\'\.$~iu', $faultString)) if (preg_match('~^Unknown setting \'.*\'\.$~iu', $faultString)) {
return new GameModeException($faultString, $faultCode); return new GameModeException($faultString, $faultCode);
if(preg_match('~^Couldn\'t load \'.*\'\.$~iu', $faultString)) }
if (preg_match('~^Couldn\'t load \'.*\'\.$~iu', $faultString)) {
return new FileException($faultString, $faultCode); return new FileException($faultString, $faultCode);
}
return new self($faultString, $faultCode); return new self($faultString, $faultCode);
} }
} }
class AuthenticationException extends FaultException {} class AuthenticationException extends FaultException {
class UnavailableFeatureException extends FaultException {} }
class LockedFeatureException extends FaultException {}
class UnknownPlayerException extends FaultException {} class UnavailableFeatureException extends FaultException {
class PlayerStateException extends FaultException {} }
class AlreadyInListException extends FaultException {}
class NotInListException extends FaultException {} class LockedFeatureException extends FaultException {
class IndexOutOfBoundException extends FaultException {} }
class NextMapException extends FaultException{}
class ChangeInProgressException extends FaultException {} class UnknownPlayerException extends FaultException {
class InvalidMapException extends FaultException{} }
class GameModeException extends FaultException {}
class ServerOptionsException extends FaultException {} class PlayerStateException extends FaultException {
class FileException extends FaultException {} }
class AlreadyInListException extends FaultException {
}
class NotInListException extends FaultException {
}
class IndexOutOfBoundException extends FaultException {
}
class NextMapException extends FaultException {
}
class ChangeInProgressException extends FaultException {
}
class InvalidMapException extends FaultException {
}
class GameModeException extends FaultException {
}
class ServerOptionsException extends FaultException {
}
class FileException extends FaultException {
}