Skip to content

Commit 9c0cfd9

Browse files
committed
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.
1 parent c1fa949 commit 9c0cfd9

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/src/server/handler.dart

+3-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ import 'interceptor.dart';
3030
import 'service.dart';
3131

3232
typedef ServiceLookup = Service? Function(String service);
33-
typedef GrpcErrorHandler = void Function(GrpcError error, StackTrace? trace);
33+
typedef GrpcErrorHandler = GrpcError? Function(
34+
GrpcError error, StackTrace? trace);
3435

3536
/// Handles an incoming gRPC call.
3637
class ServerHandler extends ServiceCall {
@@ -454,7 +455,7 @@ class ServerHandler extends ServiceCall {
454455
}
455456

456457
void _sendError(GrpcError error, [StackTrace? trace]) {
457-
_errorHandler?.call(error, trace);
458+
error = _errorHandler?.call(error, trace) ?? error;
458459

459460
sendTrailers(
460461
status: error.code,

0 commit comments

Comments
 (0)