Skip to content

Commit 3be1b33

Browse files
committed
Daemon\Server: Enhance error logging
1 parent c18ad41 commit 3be1b33

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

library/Notifications/Daemon/Server.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace Icinga\Module\Notifications\Daemon;
66

7-
use Exception;
87
use Fig\Http\Message\StatusCodeInterface;
98
use Icinga\Application\Config;
109
use Icinga\Application\Logger;
@@ -20,6 +19,7 @@
2019
use React\Http\Message\Response;
2120
use React\Socket\ConnectionInterface;
2221
use React\Socket\SocketServer;
22+
use Throwable;
2323

2424
class Server
2525
{
@@ -106,12 +106,15 @@ public function load(): void
106106
$this->http = new HttpServer(function (ServerRequestInterface $request) {
107107
return $this->handleRequest($request);
108108
});
109+
$this->http->on('error', function (Throwable $error) {
110+
self::$logger::error(self::PREFIX . "received an error on the http server: %s", $error);
111+
});
109112
// subscribe to socket events
110113
$this->socket->on('connection', function (ConnectionInterface $connection) {
111114
$this->onSocketConnection($connection);
112115
});
113-
$this->socket->on('error', function (Exception $error) {
114-
self::$logger::error(self::PREFIX . "received an error on the socket: " . $error->getMessage());
116+
$this->socket->on('error', function (Throwable $error) {
117+
self::$logger::error(self::PREFIX . "received an error on the socket: %s", $error);
115118
});
116119
// attach http server to socket
117120
$this->http->listen($this->socket);

0 commit comments

Comments
 (0)