Package io.nitric.api
Class NitricException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- io.nitric.api.NitricException
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
InvalidArgumentException
,NotFoundException
,UnavailableException
public class NitricException extends RuntimeException
Provides a Nitric Service API exception class. NitricException objects may be thrown by the Service API when performing underlying GRPC service calls.
- See Also:
NotFoundException
,UnavailableException
, Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
NitricException.Code
The gRPC status error codes.
-
Constructor Summary
Constructors Constructor Description NitricException(NitricException.Code code, String message, io.grpc.StatusRuntimeException cause, io.nitric.proto.error.v1.ErrorDetails ed)
Create a new NitricException with the given information.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static NitricException
build(io.grpc.StatusRuntimeException sre)
Create a new Nitric API Exception from the GRPC StatusRuntimeException.Map<String,String>
getArgs()
Return the plugin method arguments.NitricException.Code
getCode()
Return the GRPC error code.String
getMessage()
Return the error message.String
getPlugin()
Return the name of the service plugin invoked, e.g.String
getRootCause()
Return the root cause of the error.String
getService()
Return the API service invoked, e.g.String
toString()
Return the string representation of this object.-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
-
-
-
-
Constructor Detail
-
NitricException
public NitricException(NitricException.Code code, String message, io.grpc.StatusRuntimeException cause, io.nitric.proto.error.v1.ErrorDetails ed)
Create a new NitricException with the given information.- Parameters:
code
- the GRPC status codemessage
- the error messagecause
- the error root causeed
- the structured GRPC error details
-
-
Method Detail
-
getCode
public NitricException.Code getCode()
Return the GRPC error code.- Returns:
- the GRPC error code
-
getMessage
public String getMessage()
Return the error message.- Overrides:
getMessage
in classThrowable
- Returns:
- the error message
-
getRootCause
public String getRootCause()
Return the root cause of the error.- Returns:
- the root cause of the error.
-
getService
public String getService()
Return the API service invoked, e.g. 'Service.Method'.- Returns:
- the name of the API service invoked.
-
getPlugin
public String getPlugin()
Return the name of the service plugin invoked, e.g. 'PluginService.Method'.- Returns:
- the name of the service plugin invoked.
-
getArgs
public Map<String,String> getArgs()
Return the plugin method arguments. Please note only non-sensitive data should be returned.- Returns:
- the plugin method arguments
-
toString
public String toString()
Return the string representation of this object.
-
build
public static NitricException build(io.grpc.StatusRuntimeException sre)
Create a new Nitric API Exception from the GRPC StatusRuntimeException.- Parameters:
sre
- the GRPC service StatusRuntimeException (required)- Returns:
- a new Nitric API Exception
-
-