Skip to content

Commit

Permalink
Updating handler.dart
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
T0bst3r committed Sep 13, 2023
1 parent c1fa949 commit 9c0cfd9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/src/server/handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 9c0cfd9

Please sign in to comment.