Class GrpcStatus


  • public final class GrpcStatus
    extends java.lang.Object
    Class representing gRPC statuses.
    See Also:
    GrpcStatusCode
    • 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 an GrpcStatusCode.UNKNOWN status 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, or null.
      • asException

        public GrpcStatusException asException​(java.util.function.Supplier<com.google.rpc.Status> applicationStatusSupplier)
        Returns the current status wrapped in a GrpcStatusException including the supplied details. The status code used by Status and the one of the GrpcStatus must be the same. Users should usually use GrpcStatusException.of(Status).
        Parameters:
        applicationStatusSupplier - the Supplier for the Status.
        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:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object