mirror of https://github.com/grpc/grpc-dart.git
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.
This commit is contained in:
parent
c1fa94951a
commit
9c0cfd978d
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue