Class RetryException

java.lang.Object
java.lang.Throwable
java.lang.Exception
org.springframework.core.retry.RetryException
All Implemented Interfaces:
Serializable, RetryState

public class RetryException extends Exception implements RetryState
Exception thrown when a RetryPolicy has been exhausted or interrupted.

A RetryException will typically contain the last exception thrown by the Retryable operation as the cause and any exceptions from previous attempts as suppressed exceptions.

Implements the RetryState interface for exposing the final outcome, as a parameter of the terminal listener methods on RetryListener.

Since:
7.0
Author:
Mahmoud Ben Hassine, Juergen Hoeller, Sam Brannen
See Also:
  • Constructor Details

    • RetryException

      public RetryException(String message, Throwable cause)
      Create a new RetryException for the supplied message and cause.
      Parameters:
      message - the detail message
      cause - the last exception thrown by the Retryable operation
  • Method Details

    • getCause

      public final Throwable getCause()
      Get the last exception thrown by the Retryable operation.
      Overrides:
      getCause in class Throwable
    • getRetryCount

      public int getRetryCount()
      Return the number of retry attempts, or 0 if no retry has been attempted after the initial invocation at all.
      Specified by:
      getRetryCount in interface RetryState
    • getExceptions

      public List<Throwable> getExceptions()
      Return all invocation exceptions encountered, in the order of occurrence.
      Specified by:
      getExceptions in interface RetryState
      Since:
      7.0.2
    • getLastException

      public Throwable getLastException()
      Return the exception from the last invocation (also exposed as the cause).
      Specified by:
      getLastException in interface RetryState
      Since:
      7.0.2