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 6, 2023
1 parent dae290c commit 40e8dfa
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 40e8dfa

Please sign in to comment.