@ExperimentalApi(value="https://github.com/grpc/grpc-java/issues/4695") public final class StatusProto extends Object
Status
.Modifier and Type | Method and Description |
---|---|
static com.google.rpc.Status |
fromStatusAndTrailers(Status status,
Metadata trailers)
Extracts the
google.rpc.Status from trailers, and makes sure they match the gRPC
status . |
static com.google.rpc.Status |
fromThrowable(Throwable t)
Extract a
Status instance from the causal chain of a Throwable . |
static StatusException |
toStatusException(com.google.rpc.Status statusProto)
Convert a
Status instance to a StatusException . |
static StatusException |
toStatusException(com.google.rpc.Status statusProto,
Metadata metadata)
Convert a
Status instance to a StatusException with additional
metadata. |
static StatusRuntimeException |
toStatusRuntimeException(com.google.rpc.Status statusProto)
Convert a
Status instance to a StatusRuntimeException . |
static StatusRuntimeException |
toStatusRuntimeException(com.google.rpc.Status statusProto,
Metadata metadata)
Convert a
Status instance to a StatusRuntimeException with
additional metadata. |
public static StatusRuntimeException toStatusRuntimeException(com.google.rpc.Status statusProto)
Status
instance to a StatusRuntimeException
.
The returned StatusRuntimeException
will wrap a Status
whose code and
description are set from the code and message in statusProto
. statusProto
will
be serialized and placed into the metadata of the returned StatusRuntimeException
.
IllegalArgumentException
- if the value of statusProto.getCode()
is not a valid
gRPC status code.public static StatusRuntimeException toStatusRuntimeException(com.google.rpc.Status statusProto, Metadata metadata)
Status
instance to a StatusRuntimeException
with
additional metadata.
The returned StatusRuntimeException
will wrap a Status
whose code and
description are set from the code and message in statusProto
. statusProto
will
be serialized and added to metadata
. metadata
will be set as the metadata of
the returned StatusRuntimeException
.
IllegalArgumentException
- if the value of statusProto.getCode()
is not a valid
gRPC status code.public static StatusException toStatusException(com.google.rpc.Status statusProto)
Status
instance to a StatusException
.
The returned StatusException
will wrap a Status
whose code and description
are set from the code and message in statusProto
. statusProto
will be
serialized and placed into the metadata of the returned StatusException
.
IllegalArgumentException
- if the value of statusProto.getCode()
is not a valid
gRPC status code.public static StatusException toStatusException(com.google.rpc.Status statusProto, Metadata metadata)
Status
instance to a StatusException
with additional
metadata.
The returned StatusException
will wrap a Status
whose code and description
are set from the code and message in statusProto
. statusProto
will be
serialized and added to metadata
. metadata
will be set as the metadata of the
returned StatusException
.
IllegalArgumentException
- if the value of statusProto.getCode()
is not a valid
gRPC status code.@Nullable public static com.google.rpc.Status fromThrowable(Throwable t)
Status
instance from the causal chain of a Throwable
.Status
instance, or null
if none exists.IllegalArgumentException
- if an embedded Status
is found and its
code does not match the gRPC Status
code.public static com.google.rpc.Status fromStatusAndTrailers(Status status, @Nullable Metadata trailers)
google.rpc.Status
from trailers, and makes sure they match the gRPC
status
. If the trailers do not contain a google.rpc.Status
, it uses
status
param to generate a google.rpc.Status
.