diff --git a/application/core/Manialinks/ManialinkManager.php b/application/core/Manialinks/ManialinkManager.php index d9392d34..78345222 100644 --- a/application/core/Manialinks/ManialinkManager.php +++ b/application/core/Manialinks/ManialinkManager.php @@ -169,8 +169,11 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener public function enableAltMenu(Player $player) { try { $success = $this->maniaControl->client->triggerModeScriptEvent('LibXmlRpc_EnableAltMenu', $player->login); - } catch(\Exception $e) { - return false; + } catch(Exception $e) { + if ($e->getMessage() == 'Not in script mode.') { + return false; + } + throw $e; } return $success; } @@ -184,8 +187,11 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener public function disableAltMenu(Player $player) { try { $success = $this->maniaControl->client->triggerModeScriptEvent('LibXmlRpc_DisableAltMenu', $player->login); - } catch(\Exception $e) { - return false; + } catch(Exception $e) { + if ($e->getMessage() == 'Not in script mode.') { + return false; + } + throw $e; } return $success; } diff --git a/application/core/Maps/MapManager.php b/application/core/Maps/MapManager.php index d9906441..3fde3ce2 100644 --- a/application/core/Maps/MapManager.php +++ b/application/core/Maps/MapManager.php @@ -330,16 +330,11 @@ class MapManager implements CallbackListener { $mapsDirectory = $this->maniaControl->server->getMapsDirectory(); if (is_readable($mapsDirectory . $map->fileName)) { $mapFetcher = new \GBXChallMapFetcher(true); - try { $mapFetcher->processFile($mapsDirectory . $map->fileName); $map->authorNick = FORMATTER::stripDirtyCodes($mapFetcher->authorNick); $map->authorEInfo = $mapFetcher->authorEInfo; $map->authorZone = $mapFetcher->authorZone; $map->comment = $mapFetcher->comment; - } catch(\Exception $e) { - // TODO: replace \Exception with api exception class (?) - trigger_error($e->getMessage()); - } } return $map; } @@ -577,8 +572,6 @@ class MapManager implements CallbackListener { * @param $mapDir * @param $login * @param $update - * @throws \Exception - * @throws \Maniaplanet\DedicatedServer\Xmlrpc\Exception */ private function processMapFile($file, MXMapInfo $mapInfo, $mapDir, $login, $update) { //Check if map is already on the server @@ -635,14 +628,7 @@ class MapManager implements CallbackListener { } // Add map to map list - try { - $this->maniaControl->client->insertMap($mapFileName); - } catch(Exception $e) { - // TODO: is it even possible that an exception other than connection errors will be thrown? - remove try-catch? - $this->maniaControl->chat->sendError("Couldn't add map to match settings!", $login); - return; - } - + $this->maniaControl->client->insertMap($mapFileName); $this->updateFullMapList(); //Update Mx MapInfo diff --git a/application/core/Server/RankingManager.php b/application/core/Server/RankingManager.php index 2a1ded5c..696a9c7d 100644 --- a/application/core/Server/RankingManager.php +++ b/application/core/Server/RankingManager.php @@ -10,6 +10,7 @@ namespace ManiaControl\Server; use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackManager; use ManiaControl\ManiaControl; +use Maniaplanet\DedicatedServer\Xmlrpc\Exception; class RankingManager implements CallbackListener { /** @@ -45,8 +46,12 @@ class RankingManager implements CallbackListener { public function onInit() { try { $this->maniaControl->client->triggerModeScriptEvent('LibXmlRpc_GetRankings', ''); - } catch(\Exception $e) { - //do nothing + } catch(Exception $e) { + if ($e->getMessage() == 'Not in script mode.') { + // do nothing + return; + } + throw $e; } }