I better error display

This commit is contained in:
a6a2f5842 2025-06-13 10:31:59 +02:00
parent 4f0dd41028
commit 9e85f2c457
2 changed files with 71 additions and 79 deletions

View File

@ -255,8 +255,7 @@ class Controller
? $trace[0]['line'] ? $trace[0]['line']
: null; : null;
// log Log::channel('websocket')->error('Send error: ' . @$p['data']['message'], $p);
Log::channel('websocket')->error('Send error: ' . $p['data']['message'], $p);
if (get_class($this->connection) === MockConnection::class) { if (get_class($this->connection) === MockConnection::class) {
$connection = clone $this->connection; $connection = clone $this->connection;

View File

@ -84,6 +84,7 @@ class Handler implements MessageComponentInterface
ConnectionInterface $connection, ConnectionInterface $connection,
MessageInterface $message MessageInterface $message
) { ) {
try {
if (! isset($connection->app)) { if (! isset($connection->app)) {
return; return;
} }
@ -121,21 +122,6 @@ class Handler implements MessageComponentInterface
Log::channel('websocket')->info('Executing event: '.$message['event']); Log::channel('websocket')->info('Executing event: '.$message['event']);
if (strpos($message['event'], 'pusher') !== false) { if (strpos($message['event'], 'pusher') !== false) {
// try {
// return Controller::controll_message(
// $connection,
// $channel,
// $message,
// $this->channelManager
// );
// } catch (Exception $e) {
// return $connection->send(json_encode([
// 'event' => $message['event'].':error',
// 'data' => [
// 'message' => $e->getMessage(),
// ],
// ]));
// }
return $connection->send(json_encode([ return $connection->send(json_encode([
'event' => $message['event'].':response', 'event' => $message['event'].':response',
'data' => [ 'data' => [
@ -174,6 +160,13 @@ class Handler implements MessageComponentInterface
} else { } else {
$this->addDataCheckLoop($connection, $message, $pid); $this->addDataCheckLoop($connection, $message, $pid);
} }
} catch (\Exception $e) {
Log::channel('websocket')->error('onMessage unhandled error: '. $e->getMessage(), [
'file' => $e->getFile(),
'line' => $e->getLine(),
'trace' => $e->getTraceAsString(),
]);
}
} }
/** /**