From 04d47fb61ff22b61b326dd551e763d443e132e9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20Schro=CC=88der?= Date: Mon, 14 Apr 2014 13:19:05 +0200 Subject: [PATCH] replaced debug notices by chat messages --- .../core/Manialinks/ManialinkManager.php | 12 +++--- application/core/Players/PlayerActions.php | 39 ++++--------------- application/core/Players/PlayerList.php | 11 ++---- 3 files changed, 17 insertions(+), 45 deletions(-) diff --git a/application/core/Manialinks/ManialinkManager.php b/application/core/Manialinks/ManialinkManager.php index 9e95d038..88c2ab83 100644 --- a/application/core/Manialinks/ManialinkManager.php +++ b/application/core/Manialinks/ManialinkManager.php @@ -132,8 +132,9 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener public function sendManialink($manialinkText, $logins = null, $timeout = 0, $hideOnClick = false) { $manialinkText = (string) $manialinkText; - if(!$manialinkText) + if(!$manialinkText) { return true; + } try { if (!$logins) { @@ -159,12 +160,10 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener return $success; } } catch(Exception $e) { - if($e->getMessage() == "Login unknown."){ + if($e->getMessage() == "Login unknown.") { return false; } - $this->maniaControl->errorHandler->triggerDebugNotice("Exception while sending Manialink: " . $e->getMessage()); - // TODO: only possible valid exception should be "wrong login" - throw others (like connection error) - return false; + throw $e; } return true; @@ -217,7 +216,8 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener // render and display xml $this->sendManialink($maniaLink, $player->login); - if ($widgetName != '') { //TODO make check by manialinkId, getter is needed to avoid uses on non main widgets + if ($widgetName != '') { + //TODO make check by manialinkId, getter is needed to avoid uses on non main widgets $this->disableAltMenu($player); // Trigger callback $this->maniaControl->callbackManager->triggerCallback(self::CB_MAIN_WINDOW_OPENED, $player, $widgetName); diff --git a/application/core/Players/PlayerActions.php b/application/core/Players/PlayerActions.php index d19f4e93..b6966c94 100644 --- a/application/core/Players/PlayerActions.php +++ b/application/core/Players/PlayerActions.php @@ -88,14 +88,7 @@ class PlayerActions { try { $this->maniaControl->client->forceSpectator($target->login, self::SPECTATOR_PLAYER); } catch(Exception $e) { - if ($e->getMessage() == 'There are too many players') { - $this->maniaControl->chat->sendError("Too many Spectators"); - return; - } else { - // TODO: only possible valid exception should be "wrong login" - throw others (like connection error) - $this->maniaControl->errorHandler->triggerDebugNotice("PlayerActions Debug Line 90: " . $e->getMessage()); - $this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $admin->login); - } + $this->maniaControl->chat->sendException($e, $admin->login); return; } @@ -103,9 +96,7 @@ class PlayerActions { try { $this->maniaControl->client->forceSpectator($target->login, self::SPECTATOR_USER_SELECTABLE); } catch(Exception $e) { - // TODO: only possible valid exception should be "wrong login" - throw others (like connection error) - $this->maniaControl->errorHandler->triggerDebugNotice("PlayerActions Debug Line 100: " . $e->getMessage()); - $this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $admin->login); + $this->maniaControl->chat->sendException($e, $admin->login); return; } } @@ -184,18 +175,13 @@ class PlayerActions { return; } - try { $this->maniaControl->client->forceSpectator($target->login, $spectatorState); } catch(Exception $e) { - if ($e->getMessage() == "There are too many spectators") { - $this->maniaControl->chat->sendError($e->getMessage(), $adminLogin); - return; - } - throw $e; + $this->maniaControl->chat->sendException($e, $admin->login); + return; } - $title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel); $chatMessage = $title . ' $<' . $admin->nickname . '$> forced $<' . $target->nickname . '$> to Spectator!'; $this->maniaControl->chat->sendInformation($chatMessage); @@ -206,14 +192,8 @@ class PlayerActions { try { $this->maniaControl->client->spectatorReleasePlayerSlot($target->login); } catch(Exception $e) { - //if ($e->getMessage() == 'The player is not a spectator') { - //$this->kickPlayer($adminLogin, $targetLogin, 'Disconnect'); - //$this->maniaControl->errorHandler->triggerDebugNotice("inaktiv spec player kicked " . $e->getMessage()); - //} else { - $this->maniaControl->errorHandler->triggerDebugNotice("PlayerActions Debug Line 183: " . $e->getMessage()); - // TODO: only possible valid exception should be "wrong login" - throw others (like connection error) - //do nothing - //} + $this->maniaControl->chat->sendException($e, $admin->login); + return; } } } @@ -381,12 +361,7 @@ class PlayerActions { $this->maniaControl->client->kick($target->login, $message); } } catch(Exception $e) { - if ($e == "Login unknown.") { - return; - } - // TODO: only possible valid exception should be "wrong login" - throw others (like connection error) - $this->maniaControl->errorHandler->triggerDebugNotice("PlayerActions Debug Line 354: " . $e->getMessage()); - $this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $admin->login); + $this->maniaControl->chat->sendException($e, $admin->login); return; } diff --git a/application/core/Players/PlayerList.php b/application/core/Players/PlayerList.php index 369c73e7..29e190df 100644 --- a/application/core/Players/PlayerList.php +++ b/application/core/Players/PlayerList.php @@ -651,8 +651,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $this->maniaControl->client->forceSpectator($adminLogin, PlayerActions::SPECTATOR_BUT_KEEP_SELECTABLE); $this->maniaControl->client->forceSpectatorTarget($adminLogin, $targetLogin, 1); } catch(Exception $e) { - $this->maniaControl->errorHandler->triggerDebugNotice("PlayerList Debug Line 653: " . $e->getMessage()); - // TODO: only possible valid exception should be "wrong login" - throw others (like connection error) + $this->maniaControl->chat->sendException($e, $adminLogin); } break; case self::ACTION_OPEN_PLAYER_DETAILED: @@ -724,10 +723,8 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $this->maniaControl->client->forceSpectator($target->login, PlayerActions::SPECTATOR_BUT_KEEP_SELECTABLE); $this->maniaControl->client->spectatorReleasePlayerSlot($target->login); } catch(Exception $e) { - if ($e->getMessage() != 'Login unknown.') { - //do nothing - // TODO: only possible valid exception should be "wrong login" - throw others (like connection error) - $this->maniaControl->errorHandler->triggerDebugNotice("PlayerList Debug Line 727: " . $e->getMessage()); + if ($e->getMessage() != 'Login unknown.' && $e->getMessage() != 'The player is not a spectator') { + $this->maniaControl->chat->sendException($e); } } }); @@ -785,4 +782,4 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $this->showPlayerList($player); } } -} \ No newline at end of file +}