Package io.dapr.exceptions
Class DaprException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
io.dapr.exceptions.DaprException
- All Implemented Interfaces:
Serializable
A Dapr's specific exception.
- See Also:
-
Constructor Summary
ConstructorDescriptionDaprException
(DaprError daprError, byte[] payload, int httpStatusCode) New exception from a server-side generated error code and message.DaprException
(DaprError daprError, Throwable cause) New exception from a server-side generated error code and message.DaprException
(String errorCode, String message, byte[] payload, int httpStatusCode) New Exception from a client-side generated error code and message.DaprException
(String errorCode, String message, DaprErrorDetails errorDetails, byte[] payload) New Exception from a client-side generated error code and message.DaprException
(String errorCode, String message, DaprErrorDetails errorDetails, byte[] payload, int httpStatusCode) New Exception from a client-side generated error code and message.DaprException
(String errorCode, String message, Throwable cause) New exception from a server-side generated error code and message.DaprException
(String errorCode, String message, Throwable cause, DaprErrorDetails errorDetails, byte[] payload) New exception from a server-side generated error code and message.DaprException
(String errorCode, String message, List<Map<String, Object>> errorDetails, byte[] payload, int httpStatusCode) New Exception from a client-side generated error code and message.DaprException
(Throwable exception) Wraps an exception into a DaprException. -
Method Summary
Modifier and TypeMethodDescriptionReturns the exception's error code.Returns the exception's error details.int
Returns the exception's http status code, 0 if not applicable.byte[]
Returns the exception's error payload (optional).static RuntimeException
Wraps an exception into DaprException (if not already DaprException).static Runnable
Wraps a runnable with a try-catch to throw DaprException.static void
Wraps an exception into DaprException (if not already DaprException).static <T> Callable<T>
Wraps a callable with a try-catch to throw DaprException.static <T> reactor.core.publisher.Flux<T>
Wraps an exception into DaprException (if not already DaprException).static <T> reactor.core.publisher.Mono<T>
Wraps an exception into DaprException (if not already DaprException).Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
DaprException
New exception from a server-side generated error code and message.- Parameters:
daprError
- Server-side error.payload
- Optional payload containing the error.httpStatusCode
- Optional http Status Code (0 if not set).
-
DaprException
New exception from a server-side generated error code and message.- Parameters:
daprError
- Client-side error.cause
- the cause (which is saved for later retrieval by theThrowable.getCause()
method). (Anull
value is permitted, and indicates that the cause is nonexistent or unknown.)
-
DaprException
Wraps an exception into a DaprException.- Parameters:
exception
- the exception to be wrapped.
-
DaprException
New Exception from a client-side generated error code and message.- Parameters:
errorCode
- Client-side error code.message
- Client-side error message.payload
- Optional payload containing the error.httpStatusCode
- Optional http Status Code (0 if not set).
-
DaprException
public DaprException(String errorCode, String message, List<Map<String, Object>> errorDetails, byte[] payload, int httpStatusCode) New Exception from a client-side generated error code and message.- Parameters:
errorCode
- Client-side error code.message
- Client-side error message.errorDetails
- Details of the error from runtime.payload
- Optional payload containing the error.httpStatusCode
- Optional http Status Code (0 if not set).
-
DaprException
public DaprException(String errorCode, String message, DaprErrorDetails errorDetails, byte[] payload) New Exception from a client-side generated error code and message.- Parameters:
errorCode
- Client-side error code.message
- Client-side error message.errorDetails
- Details of the error from runtime.payload
- Optional payload containing the error.
-
DaprException
public DaprException(String errorCode, String message, DaprErrorDetails errorDetails, byte[] payload, int httpStatusCode) New Exception from a client-side generated error code and message.- Parameters:
errorCode
- Client-side error code.message
- Client-side error message.errorDetails
- Details of the error from runtime.payload
- Optional payload containing the error.httpStatusCode
- Optional http Status Code (0 if not set).
-
DaprException
New exception from a server-side generated error code and message.- Parameters:
errorCode
- Client-side error code.message
- Client-side error message.cause
- the cause (which is saved for later retrieval by theThrowable.getCause()
method). (Anull
value is permitted, and indicates that the cause is nonexistent or unknown.)
-
DaprException
public DaprException(String errorCode, String message, Throwable cause, DaprErrorDetails errorDetails, byte[] payload) New exception from a server-side generated error code and message.- Parameters:
errorCode
- Client-side error code.message
- Client-side error message.cause
- the cause (which is saved for later retrieval by theThrowable.getCause()
method). (Anull
value is permitted, and indicates that the cause is nonexistent or unknown.)errorDetails
- the status details for the error.payload
- Raw error payload.
-
-
Method Details
-
getErrorCode
Returns the exception's error code.- Returns:
- Error code.
-
getErrorDetails
Returns the exception's error details.- Returns:
- Error details.
-
getPayload
public byte[] getPayload()Returns the exception's error payload (optional).- Returns:
- Error's payload.
-
getHttpStatusCode
public int getHttpStatusCode()Returns the exception's http status code, 0 if not applicable.- Returns:
- Http status code (0 if not applicable).
-
wrap
Wraps an exception into DaprException (if not already DaprException).- Parameters:
exception
- Exception to be wrapped.
-
wrap
Wraps a callable with a try-catch to throw DaprException.- Type Parameters:
T
- type to be returned- Parameters:
callable
- callable to be invoked.- Returns:
- object of type T.
-
wrap
Wraps a runnable with a try-catch to throw DaprException.- Parameters:
runnable
- runnable to be invoked.- Returns:
- object of type T.
-
wrapMono
Wraps an exception into DaprException (if not already DaprException).- Type Parameters:
T
- Mono's response type.- Parameters:
exception
- Exception to be wrapped.- Returns:
- Mono containing DaprException.
-
wrapFlux
Wraps an exception into DaprException (if not already DaprException).- Type Parameters:
T
- Flux's response type.- Parameters:
exception
- Exception to be wrapped.- Returns:
- Flux containing DaprException.
-
propagate
Wraps an exception into DaprException (if not already DaprException).- Parameters:
exception
- Exception to be wrapped.- Returns:
- wrapped RuntimeException
-