Table of Contents

Class FromRpcExceptionToResultExtension

Namespace
Arc4u.gRPC.Results
Assembly
Arc4u.gRPC.dll

Turns the fault of a gRPC call back into a failed FluentResults.Result. It is the client-side counterpart of FromResultToRpcExceptionExtension in Arc4u.AspNetCore.gRpc: the server packs the ProblemDetails of a failed result in the google.rpc.Status of the grpc-status-details-bin trailer, and this extension turns it back into the errors Arc4u builds that document from. Rendered with ToProblemDetails(), they give back the very document the server produced.

public static class FromRpcExceptionToResultExtension
Inheritance
FromRpcExceptionToResultExtension
Inherited Members

Methods

ToProblemDetailError(RpcException)

Converts a gRPC fault into the ProblemDetailError describing it.

public static ProblemDetailError ToProblemDetailError(this RpcException exception)

Parameters

exception RpcException

The fault raised by the gRPC client.

Returns

ProblemDetailError

An error rebuilt from the ProblemDetails the server sent in the status details, or - when the fault carries none, as for a transport failure that never reached the service - one derived from the gRPC status alone.

Remarks

The messages of a validation failure do not fit in a ProblemDetailError: use ToResult(RpcException) to keep them.

ToResult(RpcException)

Converts a gRPC fault into a failed FluentResults.Result.

public static Result ToResult(this RpcException exception)

Parameters

exception RpcException

The fault raised by the gRPC client.

Returns

Result

A failed FluentResults.Result carrying the ProblemDetails of the remote failure.

ToResult<TValue>(RpcException)

Converts a gRPC fault into a failed FluentResults.Result<TValue>.

public static Result<TValue> ToResult<TValue>(this RpcException exception)

Parameters

exception RpcException

The fault raised by the gRPC client.

Returns

Result<TValue>

A failed FluentResults.Result<TValue> carrying the ProblemDetails of the remote failure.

Type Parameters

TValue

The type the result would have carried on success.