Consistent Exception handling for WAMP protocol errors

This commit is contained in:
Christian Lück 2014-05-19 15:46:18 +02:00
parent 02a63c180d
commit fb1ba88fcc
2 changed files with 3 additions and 3 deletions

View File

@ -90,7 +90,7 @@ class ServerProtocol implements MessageComponentInterface, WsServerInterface {
} }
if (!is_array($json) || $json !== array_values($json)) { if (!is_array($json) || $json !== array_values($json)) {
throw new \UnexpectedValueException("Invalid WAMP message format"); throw new Exception("Invalid WAMP message format");
} }
switch ($json[0]) { switch ($json[0]) {
@ -134,7 +134,7 @@ class ServerProtocol implements MessageComponentInterface, WsServerInterface {
break; break;
default: default:
throw new Exception('Invalid message type'); throw new Exception('Invalid WAMP message type');
} }
} }

View File

@ -39,7 +39,7 @@ class WampServer implements MessageComponentInterface, WsServerInterface {
public function onMessage(ConnectionInterface $conn, $msg) { public function onMessage(ConnectionInterface $conn, $msg) {
try { try {
$this->wampProtocol->onMessage($conn, $msg); $this->wampProtocol->onMessage($conn, $msg);
} catch (JsonException $je) { } catch (Exception $je) {
$conn->close(1007); $conn->close(1007);
} catch (\UnexpectedValueException $uve) { } catch (\UnexpectedValueException $uve) {
$conn->close(1007); $conn->close(1007);