Package com.linecorp.armeria.common.grpc
Interface GoogleGrpcExceptionHandlerFunction
- All Superinterfaces:
GrpcExceptionHandlerFunction
@UnstableApi
public interface GoogleGrpcExceptionHandlerFunction
extends GrpcExceptionHandlerFunction
A
GoogleGrpcExceptionHandlerFunction
that provides a way to include details of a status into
a Metadata
. You can implement a mapping function to convert Throwable
into
a Status
which is stored in the `grpc-status-details-bin` key in the Metadata
.
If a given Throwable
is an instance of either StatusRuntimeException
or
StatusException
, the Status
retrieved from the exception is
returned with higher priority.-
Method Summary
Modifier and TypeMethodDescriptiondefault @Nullable io.grpc.Status
apply
(RequestContext ctx, io.grpc.Status status, Throwable throwable, io.grpc.Metadata metadata) @Nullable com.google.rpc.Status
applyStatusProto
(RequestContext ctx, Throwable throwable, io.grpc.Metadata metadata) Methods inherited from interface com.linecorp.armeria.common.grpc.GrpcExceptionHandlerFunction
orElse
-
Method Details
-
apply
@Nullable default @Nullable io.grpc.Status apply(RequestContext ctx, io.grpc.Status status, Throwable throwable, io.grpc.Metadata metadata) Description copied from interface:GrpcExceptionHandlerFunction
Maps the specifiedThrowable
to a gRPCStatus
and mutates the specifiedMetadata
. Ifnull
is returned,GrpcExceptionHandlerFunction.of()
will be used to returnStatus
as the default.The specified
Status
parameter was created viaStatus.fromThrowable(Throwable)
. You can return theStatus
or any otherStatus
as needed.- Specified by:
apply
in interfaceGrpcExceptionHandlerFunction
-
applyStatusProto
@Nullable com.google.rpc.Status applyStatusProto(RequestContext ctx, Throwable throwable, io.grpc.Metadata metadata) Maps the specifiedThrowable
to aStatus
, and mutates the specifiedMetadata
. The `grpc-status-details-bin` key is ignored since it will be overwritten byGrpcExceptionHandlerFunction.apply(RequestContext, Status, Throwable, Metadata)
. Ifnull
is returned, the built-in mapping rule is used by default.
-