Package io.servicetalk.grpc.api
Class GrpcStatus
- java.lang.Object
-
- io.servicetalk.grpc.api.GrpcStatus
-
public final class GrpcStatus extends java.lang.ObjectClass representing gRPC statuses.- See Also:
GrpcStatusCode
-
-
Constructor Summary
Constructors Constructor Description GrpcStatus(GrpcStatusCode code)Constructs a status with no cause or description.GrpcStatus(GrpcStatusCode code, java.lang.Throwable cause)Constructs a status with cause but no additional description.GrpcStatus(GrpcStatusCode code, java.lang.Throwable cause, java.lang.CharSequence description)Constructs a status with cause and additional description.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description GrpcStatusExceptionasException()Returns the current status wrapped in aGrpcStatusException.GrpcStatusExceptionasException(java.util.function.Supplier<com.google.rpc.Status> applicationStatusSupplier)Returns the current status wrapped in aGrpcStatusExceptionincluding the supplied details.java.lang.Throwablecause()Returns the cause, can be null.GrpcStatusCodecode()Returns the status code.java.lang.Stringdescription()Returns additional descriptions, can be null.booleanequals(java.lang.Object o)static GrpcStatusfromCodeValue(int codeValue)Obtains the status given an integer code value.static GrpcStatusfromCodeValue(java.lang.String codeValue)Obtains the status given a code value string.static GrpcStatusfromThrowable(java.lang.Throwable t)Translates a throwable into a status.static GrpcStatusfromThrowableNullable(java.lang.Throwable t)Translates a throwable into a status.inthashCode()java.lang.StringtoString()
-
-
-
Constructor Detail
-
GrpcStatus
public GrpcStatus(GrpcStatusCode code)
Constructs a status with no cause or description.- Parameters:
code- status code.
-
GrpcStatus
public GrpcStatus(GrpcStatusCode code, @Nullable java.lang.Throwable cause)
Constructs a status with cause but no additional description.- Parameters:
code- status code.cause- cause.
-
GrpcStatus
public GrpcStatus(GrpcStatusCode code, @Nullable java.lang.Throwable cause, @Nullable java.lang.CharSequence description)
Constructs a status with cause and additional description.- Parameters:
code- status code.cause- cause.description- additional description.
-
-
Method Detail
-
fromCodeValue
public static GrpcStatus fromCodeValue(java.lang.String codeValue)
Obtains the status given a code value string.- Parameters:
codeValue- code value string.- Returns:
- status associated with the code value, or
GrpcStatusCode.UNKNOWN.
-
fromCodeValue
public static GrpcStatus fromCodeValue(int codeValue)
Obtains the status given an integer code value.- Parameters:
codeValue- integer code value.- Returns:
- status associated with the code value, or
GrpcStatusCode.UNKNOWN.
-
fromThrowable
public static GrpcStatus fromThrowable(java.lang.Throwable t)
Translates a throwable into a status.- Parameters:
t- the throwable.- Returns:
- embedded status if the throwable is a
GrpcStatusException, or anGrpcStatusCode.UNKNOWNstatus with the throwable as the cause.
-
fromThrowableNullable
@Nullable public static GrpcStatus fromThrowableNullable(java.lang.Throwable t)
Translates a throwable into a status.- Parameters:
t- the throwable.- Returns:
- embedded status if the throwable is a
GrpcStatusException, ornull.
-
asException
public GrpcStatusException asException()
Returns the current status wrapped in aGrpcStatusException.- Returns:
- the current status wrapped in a
GrpcStatusException.
-
asException
public GrpcStatusException asException(java.util.function.Supplier<com.google.rpc.Status> applicationStatusSupplier)
Returns the current status wrapped in aGrpcStatusExceptionincluding the supplied details. The status code used byStatusand the one of theGrpcStatusmust be the same. Users should usually useGrpcStatusException.of(Status).- Parameters:
applicationStatusSupplier- theSupplierfor theStatus.- Returns:
- the current status wrapped in a
GrpcStatusException.
-
code
public GrpcStatusCode code()
Returns the status code.- Returns:
- the status code.
-
cause
@Nullable public java.lang.Throwable cause()
Returns the cause, can be null.- Returns:
- the cause, can be null.
-
description
@Nullable public java.lang.String description()
Returns additional descriptions, can be null.- Returns:
- additional descriptions, can be null.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-