From 21529c6be71eef37e20f105c898c2e37c41d963c Mon Sep 17 00:00:00 2001 From: Sigurd Meldgaard Date: Thu, 29 Oct 2020 12:57:47 +0100 Subject: [PATCH] Don't print from server (#212) Co-authored-by: Vyacheslav Egorov --- lib/src/server/server.dart | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/src/server/server.dart b/lib/src/server/server.dart index 3f13a31..8a2a4d3 100644 --- a/lib/src/server/server.dart +++ b/lib/src/server/server.dart @@ -105,8 +105,10 @@ class ConnectionServer { // timeout. connection.incomingStreams.listen((stream) { handler = serveStream_(stream); - }, onError: (error) { - print('Connection error: $error'); + }, onError: (error, stackTrace) { + if (error is Error) { + Zone.current.handleUncaughtError(error, stackTrace); + } }, onDone: () { // TODO(sigurdm): This is not correct behavior in the presence of // half-closed tcp streams. @@ -175,11 +177,11 @@ class Server extends ConnectionServer { final connection = ServerTransportConnection.viaSocket(socket, settings: http2ServerSettings); serveConnection(connection); - }, onError: _printSocketError); - } - - void _printSocketError(Object error) { - print('Socket error: $error'); + }, onError: (error, stackTrace) { + if (error is Error) { + Zone.current.handleUncaughtError(error, stackTrace); + } + }); } @visibleForTesting