From 40e8dfaad71e1f6df4ad895aa9c608c5efc16dfd Mon Sep 17 00:00:00 2001 From: tobias Date: Wed, 6 Sep 2023 17:25:44 +0200 Subject: [PATCH] Updating handler.dart Adding these changes allows for the error handler to have more uses. This allows for internal errors to not only be logged, but also be obfuscated to remove sensitive information or extended to add the stack trace for simpler debugging. --- lib/src/server/handler.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/src/server/handler.dart b/lib/src/server/handler.dart index ecbebe1e..4fb63f7a 100644 --- a/lib/src/server/handler.dart +++ b/lib/src/server/handler.dart @@ -30,7 +30,8 @@ import 'interceptor.dart'; import 'service.dart'; typedef ServiceLookup = Service? Function(String service); -typedef GrpcErrorHandler = void Function(GrpcError error, StackTrace? trace); +typedef GrpcErrorHandler = GrpcError? Function( + GrpcError error, StackTrace? trace); /// Handles an incoming gRPC call. class ServerHandler extends ServiceCall { @@ -454,7 +455,7 @@ class ServerHandler extends ServiceCall { } void _sendError(GrpcError error, [StackTrace? trace]) { - _errorHandler?.call(error, trace); + error = _errorHandler?.call(error, trace) ?? error; sendTrailers( status: error.code,