protected override void ThrowOrIgnoreCore(ClientCallInterceptorContext context, ClientFaultDetail detail) { if (detail.Detail is ExceptionDetail error) { throw new ServerException(error, detail.OriginalError); } }
public AsyncStreamReaderInterceptor( IAsyncStreamReader <TResponse> original, ClientCallInterceptorContext context, IClientCallInterceptor interceptor) { _original = original; _context = context; _interceptor = interceptor; }
public void ThrowOrIgnore(ClientCallInterceptorContext context, ClientFaultDetail detail) { // if marker is UnexpectedErrorDetail if (detail.Detail is UnexpectedErrorDetail unexpectedErrorDetail) { // throw custom exception throw new UnexpectedErrorException(unexpectedErrorDetail); } }
public void ThrowOrIgnore(ClientCallInterceptorContext context, ClientFaultDetail detail) { // if marker is ApplicationException if ((detail.Detail is string name) && name == "ApplicationException") { // throw custom exception throw new ApplicationException(detail.OriginalError.Status.Detail); } }
public ClientStreamWriterInterceptor( IClientStreamWriter <TRequest> original, ClientCallInterceptorContext context, IClientCallInterceptor interceptor) { _original = original; _context = context; _interceptor = interceptor; }
private async Task <TResponse> WaitAsyncUnaryCall <TResponse>( ClientCallInterceptorContext context, Task <TResponse> responseAsync) where TResponse : class { try { return(await responseAsync.ConfigureAwait(false)); } catch (RpcException ex) { CallInterceptor.OnError(context, ex); throw; } }
public void OnError(ClientCallInterceptorContext context, RpcException error) { object?detail = null; if (TryFindHeaders(error.Trailers, out var detailTypeName, out var detailContent)) { var detailType = ResolveDetailType(detailTypeName); if (detailType != null) { detail = MarshallerFactory.DeserializeHeader(detailType, detailContent); } } ErrorHandler.ThrowOrIgnore(context, new ClientFaultDetail(error, detail)); }
protected override void ThrowOrIgnoreCore(ClientCallInterceptorContext context, ClientFaultDetail detail) { // handle ApplicationExceptionFaultDetail if (detail.Detail is ApplicationExceptionFaultDetail appDetail) { throw new FaultException <ApplicationExceptionFaultDetail>(appDetail); } // handle InvalidOperationExceptionFaultDetail if (detail.Detail is InvalidOperationExceptionFaultDetail opDetail) { throw new FaultException <InvalidOperationExceptionFaultDetail>(opDetail); } // ignore other errors }
public override AsyncServerStreamingCall <TResponse> AsyncServerStreamingCall <TRequest, TResponse>( TRequest request, ClientInterceptorContext <TRequest, TResponse> context, AsyncServerStreamingCallContinuation <TRequest, TResponse> continuation) { var callContext = new ClientCallInterceptorContext(context.Options, context.Host, context.Method); var call = base.AsyncServerStreamingCall(request, context, continuation); return(new AsyncServerStreamingCall <TResponse>( new AsyncStreamReaderInterceptor <TResponse>(call.ResponseStream, callContext, CallInterceptor), call.ResponseHeadersAsync, call.GetStatus, call.GetTrailers, call.Dispose)); }
public void BeforeEachTest() { _logger = new LoggerMock(); _errorHandler = new Mock <IClientErrorHandler>(MockBehavior.Strict); _context = new ClientCallInterceptorContext(default, "host", new Mock <IMethod>(MockBehavior.Strict).Object);