public override Task <TResponse> UnaryServerHandler <TRequest, TResponse>(TRequest request, ServerCallContext context, UnaryServerMethod <TRequest, TResponse> continuation) { return(continuation(request, context).ContinueWith(task => { if (task.Exception == null) { return task.Result; } if (task.Exception != null && task.Exception.InnerExceptions.All(exception => exception is RpcException)) { return task.Result; } _breadcrumber.MessageBreadcrumb(request); _breadcrumber.ContextBreadcrumb(context); _breadcrumber.MethodBreadcrumb(continuation.Method); var exceptions = task.Exception.InnerExceptions.Where(e => !(e.InnerException is RpcException)); foreach (var exception in exceptions) { _sentryClient.Capture(new SentryEvent(exception)); } throw task.Exception; }, TaskContinuationOptions.OnlyOnFaulted)); }
public override async Task <TResponse> UnaryServerHandler <TRequest, TResponse>(TRequest request, ServerCallContext context, UnaryServerMethod <TRequest, TResponse> continuation) { try { return(await continuation(request, context)); } catch (RpcException) { throw; } catch (Exception e) { _breadcrumber.GeneralInformationBreadcrumb(); _breadcrumber.MessageBreadcrumb(request); _breadcrumber.ContextBreadcrumb(context); _breadcrumber.MethodBreadcrumb(continuation.Method); _sentryClient.Capture(new SentryEvent(e)); throw; } }