Table of Contents

Class FromResultToRpcExceptionExtension

Namespace
Arc4u.AspNetCore.gRpc.Results
Assembly
Arc4u.AspNetCore.gRpc.dll

Turns a failed FluentResults.Result into the fault a gRPC service throws. Everything is derived from the very ProblemDetails the REST endpoints return (ToProblemDetails()), so both transports report a failure identically. The ProblemDetails itself travels along following the gRPC richer error model: packed as an arc4u.grpc.v1.ProblemDetails in the google.rpc.Status of the grpc-status-details-bin trailer, which every gRPC language has a helper to read. The .NET client-side counterpart is FromRpcExceptionToResultExtension in Arc4u.gRPC.

public static class FromResultToRpcExceptionExtension
Inheritance
FromResultToRpcExceptionExtension
Inherited Members

Methods

ToRpcException(Result)

Converts a failed result into the RpcException to throw back to the caller.

public static RpcException ToRpcException(this Result result)

Parameters

result Result

The failed result to convert.

Returns

RpcException

An RpcException carrying the gRPC equivalent of the result's ProblemDetails.

Remarks

As with ToProblemDetails(), converting a successful result is a programming error: it is reported as an unexpected failure.

ToRpcException<TValue>(Result<TValue>)

Converts a failed result into the RpcException to throw back to the caller.

public static RpcException ToRpcException<TValue>(this Result<TValue> result)

Parameters

result Result<TValue>

The failed result to convert.

Returns

RpcException

An RpcException carrying the gRPC equivalent of the result's ProblemDetails.

Type Parameters

TValue

The type carried by the result.

Remarks

As with ToProblemDetails(), converting a successful result is a programming error: it is reported as an unexpected failure.