Class GrpcException

All Implemented Interfaces:
Serializable

public class GrpcException extends RuntimeException

Base exception class used to report gRPC errors.

Since:
1.9
Author:
Jeremy Kuhn
See Also:
  • Constructor Details

    • GrpcException

      public GrpcException()

      Creates a gRPC exception with default status GrpcStatus.INTERNAL.

    • GrpcException

      public GrpcException(String message)

      Creates a gRPC exception with default status GrpcStatus.INTERNAL and specified message.

      Parameters:
      message - a message
    • GrpcException

      public GrpcException(Throwable cause)

      Creates a gRPC exception with default status GrpcStatus.INTERNAL and specified cause.

      Parameters:
      cause - a cause
    • GrpcException

      public GrpcException(String message, Throwable cause)

      Creates a gRPC exception with default status GrpcStatus.INTERNAL, specified message and cause.

      Parameters:
      message - a message
      cause - a cause
    • GrpcException

      public GrpcException(int statusCode) throws IllegalArgumentException

      Creates a gRPC exception with specified gRPC status code.

      Parameters:
      statusCode - a gRPC status code
      Throws:
      IllegalArgumentException - if the specified status code is invalid
    • GrpcException

      public GrpcException(int statusCode, String message) throws IllegalArgumentException

      Creates a gRPC exception with specified gRPC status code and message.

      Parameters:
      statusCode - a gRPC status code
      message - a message
      Throws:
      IllegalArgumentException - if the specified status code is invalid
    • GrpcException

      public GrpcException(int statusCode, Throwable cause) throws IllegalArgumentException

      Creates a gRPC exception with specified gRPC status code and cause.

      Parameters:
      statusCode - a gRPC status code
      cause - a cause
      Throws:
      IllegalArgumentException - if the specified status code is invalid
    • GrpcException

      public GrpcException(int statusCode, String message, Throwable cause) throws IllegalArgumentException

      Creates a gRPC exception with specified gRPC status code, message and cause.

      Parameters:
      statusCode - a gRPC status code
      message - a message
      cause - a cause
      Throws:
      IllegalArgumentException - if the specified status code is invalid
    • GrpcException

      public GrpcException(GrpcStatus status)

      Creates a gRPC exception with specified gRPC status.

      Parameters:
      status - a gRPC status
    • GrpcException

      public GrpcException(GrpcStatus status, String message)

      Creates a gRPC exception with specified gRPC status and message.

      Parameters:
      status - a gRPC status
      message - a message
    • GrpcException

      public GrpcException(GrpcStatus status, Throwable cause)

      Creates a gRPC exception with specified gRPC status and cause.

      Parameters:
      status - a gRPC status
      cause - a cause
    • GrpcException

      public GrpcException(GrpcStatus status, String message, Throwable cause)

      Creates a gRPC exception with specified gRPC status, message and cause.

      Parameters:
      status - a gRPC status
      message - a message
      cause - a cause
  • Method Details

    • getStatusCode

      public int getStatusCode()

      Returns the gRPC status code.

      Returns:
      a gRPC status code
    • getStatus

      public GrpcStatus getStatus()

      Returns the gRPC status.

      Returns:
      a gRPC status or null if the code specified does correspond to any known status
    • wrap

      public static GrpcException wrap(Throwable error)

      Wraps the specified error into an GrpcException.

      The specified error is returned untouched if it is already an GrpcException instance, ohterwise it is wrapped in a GrpcException with GrpcStatus.INTERNAL code.

      Parameters:
      error - the error to wrap
      Returns:
      the specified error if it is a GrpcException, a GrpcException wrapping the specified error otherwise