Class DaprException

java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
io.dapr.exceptions.DaprException
All Implemented Interfaces:
java.io.Serializable

public class DaprException
extends java.lang.RuntimeException
A Dapr's specific exception.
See Also:
Serialized Form
  • Constructor Summary

    Constructors
    Constructor Description
    DaprException​(DaprError daprError)
    New exception from a server-side generated error code and message.
    DaprException​(DaprError daprError, java.lang.Throwable cause)
    New exception from a server-side generated error code and message.
    DaprException​(java.lang.String errorCode, java.lang.String message)
    New Exception from a client-side generated error code and message.
    DaprException​(java.lang.String errorCode, java.lang.String message, java.lang.Throwable cause)
    New exception from a server-side generated error code and message.
    DaprException​(java.lang.Throwable exception)
    Wraps an exception into a DaprException.
  • Method Summary

    Modifier and Type Method Description
    java.lang.String getErrorCode()
    Returns the exception's error code.
    static java.lang.RuntimeException propagate​(java.lang.Throwable exception)
    Wraps an exception into DaprException (if not already DaprException).
    static java.lang.Runnable wrap​(java.lang.Runnable runnable)
    Wraps a runnable with a try-catch to throw DaprException.
    static void wrap​(java.lang.Throwable exception)
    Wraps an exception into DaprException (if not already DaprException).
    static <T> java.util.concurrent.Callable<T> wrap​(java.util.concurrent.Callable<T> callable)
    Wraps a callable with a try-catch to throw DaprException.
    static <T> reactor.core.publisher.Mono<T> wrapMono​(java.lang.Exception exception)
    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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • DaprException

      public DaprException​(DaprError daprError)
      New exception from a server-side generated error code and message.
      Parameters:
      daprError - Server-side error.
    • DaprException

      public DaprException​(DaprError daprError, java.lang.Throwable cause)
      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 the Throwable.getCause() method). (A null value is permitted, and indicates that the cause is nonexistent or unknown.)
    • DaprException

      public DaprException​(java.lang.Throwable exception)
      Wraps an exception into a DaprException.
      Parameters:
      exception - the exception to be wrapped.
    • DaprException

      public DaprException​(java.lang.String errorCode, java.lang.String message)
      New Exception from a client-side generated error code and message.
      Parameters:
      errorCode - Client-side error code.
      message - Client-side error message.
    • DaprException

      public DaprException​(java.lang.String errorCode, java.lang.String message, java.lang.Throwable cause)
      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 the Throwable.getCause() method). (A null value is permitted, and indicates that the cause is nonexistent or unknown.)
  • Method Details

    • getErrorCode

      public java.lang.String getErrorCode()
      Returns the exception's error code.
      Returns:
      Error code.
    • wrap

      public static void wrap​(java.lang.Throwable exception)
      Wraps an exception into DaprException (if not already DaprException).
      Parameters:
      exception - Exception to be wrapped.
    • wrap

      public static <T> java.util.concurrent.Callable<T> wrap​(java.util.concurrent.Callable<T> callable)
      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

      public static java.lang.Runnable wrap​(java.lang.Runnable runnable)
      Wraps a runnable with a try-catch to throw DaprException.
      Parameters:
      runnable - runnable to be invoked.
      Returns:
      object of type T.
    • wrapMono

      public static <T> reactor.core.publisher.Mono<T> wrapMono​(java.lang.Exception exception)
      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.
    • propagate

      public static java.lang.RuntimeException propagate​(java.lang.Throwable exception)
      Wraps an exception into DaprException (if not already DaprException).
      Parameters:
      exception - Exception to be wrapped.
      Returns:
      wrapped RuntimeException