Class StatusProto
- java.lang.Object
-
- io.grpc.protobuf.StatusProto
-
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/4695") public final class StatusProto extends java.lang.ObjectUtility methods for working withStatus.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static com.google.rpc.StatusfromStatusAndTrailers(io.grpc.Status status, io.grpc.Metadata trailers)Extracts thegoogle.rpc.Statusfrom trailers, and makes sure they match the gRPCstatus.static com.google.rpc.StatusfromThrowable(java.lang.Throwable t)Extract aStatusinstance from the causal chain of aThrowable.static io.grpc.StatusExceptiontoStatusException(com.google.rpc.Status statusProto)Convert aStatusinstance to aStatusException.static io.grpc.StatusExceptiontoStatusException(com.google.rpc.Status statusProto, io.grpc.Metadata metadata)Convert aStatusinstance to aStatusExceptionwith additional metadata.static io.grpc.StatusRuntimeExceptiontoStatusRuntimeException(com.google.rpc.Status statusProto)Convert aStatusinstance to aStatusRuntimeException.static io.grpc.StatusRuntimeExceptiontoStatusRuntimeException(com.google.rpc.Status statusProto, io.grpc.Metadata metadata)Convert aStatusinstance to aStatusRuntimeExceptionwith additional metadata.
-
-
-
Method Detail
-
toStatusRuntimeException
public static io.grpc.StatusRuntimeException toStatusRuntimeException(com.google.rpc.Status statusProto)
Convert aStatusinstance to aStatusRuntimeException.The returned
StatusRuntimeExceptionwill wrap aStatuswhose code and description are set from the code and message instatusProto.statusProtowill be serialized and placed into the metadata of the returnedStatusRuntimeException.- Throws:
java.lang.IllegalArgumentException- if the value ofstatusProto.getCode()is not a valid gRPC status code.- Since:
- 1.3.0
-
toStatusRuntimeException
public static io.grpc.StatusRuntimeException toStatusRuntimeException(com.google.rpc.Status statusProto, io.grpc.Metadata metadata)Convert aStatusinstance to aStatusRuntimeExceptionwith additional metadata.The returned
StatusRuntimeExceptionwill wrap aStatuswhose code and description are set from the code and message instatusProto.statusProtowill be serialized and added tometadata.metadatawill be set as the metadata of the returnedStatusRuntimeException.- Throws:
java.lang.IllegalArgumentException- if the value ofstatusProto.getCode()is not a valid gRPC status code.- Since:
- 1.3.0
-
toStatusException
public static io.grpc.StatusException toStatusException(com.google.rpc.Status statusProto)
Convert aStatusinstance to aStatusException.The returned
StatusExceptionwill wrap aStatuswhose code and description are set from the code and message instatusProto.statusProtowill be serialized and placed into the metadata of the returnedStatusException.- Throws:
java.lang.IllegalArgumentException- if the value ofstatusProto.getCode()is not a valid gRPC status code.- Since:
- 1.3.0
-
toStatusException
public static io.grpc.StatusException toStatusException(com.google.rpc.Status statusProto, io.grpc.Metadata metadata)Convert aStatusinstance to aStatusExceptionwith additional metadata.The returned
StatusExceptionwill wrap aStatuswhose code and description are set from the code and message instatusProto.statusProtowill be serialized and added tometadata.metadatawill be set as the metadata of the returnedStatusException.- Throws:
java.lang.IllegalArgumentException- if the value ofstatusProto.getCode()is not a valid gRPC status code.- Since:
- 1.3.0
-
fromThrowable
@Nullable public static com.google.rpc.Status fromThrowable(java.lang.Throwable t)
Extract aStatusinstance from the causal chain of aThrowable.- Returns:
- the extracted
Statusinstance, ornullif none exists. - Throws:
java.lang.IllegalArgumentException- if an embeddedStatusis found and its code does not match the gRPCStatuscode.- Since:
- 1.3.0
-
fromStatusAndTrailers
public static com.google.rpc.Status fromStatusAndTrailers(io.grpc.Status status, @Nullable io.grpc.Metadata trailers)Extracts thegoogle.rpc.Statusfrom trailers, and makes sure they match the gRPCstatus. If the trailers do not contain agoogle.rpc.Status, it usesstatusparam to generate agoogle.rpc.Status.- Returns:
- the embedded google.rpc.Status
- Since:
- 1.11.0
-
-