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); } }
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 }
protected override void ThrowOrIgnoreCore(ClientCallInterceptorContext context, ClientFaultDetail detail) { if (detail.Detail is ExceptionDetail error) { throw new ServerException(error, detail.OriginalError); } }