Class ApplicationFailure
- All Implemented Interfaces:
Serializable
Throw this exception to have full control over type and details if the exception delivered to the caller workflow or client.
Any unhandled exception which doesn't extend TemporalFailure is converted to an
instance of this class before being returned to a caller.
The type property is used by RetryOptions to determine if
an instance of this exception is non retryable. Another way to avoid retrying an exception of
this type is by setting nonRetryable flag to @{code true}.
The conversion of an exception that doesn't extend TemporalFailure to an
ApplicationFailure is done as following:
- type is set to the exception full type name.
- message is set to the exception message
- nonRetryable is set to false
- details are set to null
- stack trace is copied from the original exception
- category is set to
ApplicationErrorCategory.UNSPECIFIED
- See Also:
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptiongetType()booleanstatic ApplicationFailure.BuilderCreates a new builder forApplicationFailure.static ApplicationFailure.BuildernewBuilder(ApplicationFailure options) Creates a new builder forApplicationFailureinitialized with the provided failure.static ApplicationFailurenewFailure(String message, String type, Object... details) New ApplicationFailure withisNonRetryable()flag set to false.static ApplicationFailurenewFailureWithCause(String message, String type, Throwable cause, Object... details) New ApplicationFailure withisNonRetryable()flag set to false.static ApplicationFailurenewFailureWithCauseAndDelay(String message, String type, Throwable cause, Duration nextRetryDelay, Object... details) New ApplicationFailure withisNonRetryable()flag set to false.static ApplicationFailurenewNonRetryableFailure(String message, String type, Object... details) New ApplicationFailure withisNonRetryable()flag set to true.static ApplicationFailurenewNonRetryableFailureWithCause(String message, String type, Throwable cause, Object... details) New ApplicationFailure withisNonRetryable()flag set to true.voidsetDataConverter(DataConverter converter) voidsetNextRetryDelay(Duration nextRetryDelay) voidsetNonRetryable(boolean nonRetryable) Methods inherited from class io.temporal.failure.TemporalFailure
getOriginalMessageMethods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Method Details
-
newBuilder
Creates a new builder forApplicationFailure. -
newBuilder
Creates a new builder forApplicationFailureinitialized with the provided failure. -
newFailure
New ApplicationFailure withisNonRetryable()flag set to false.Note that this exception still may not be retried by the service if its type is included in the doNotRetry property of the correspondent retry policy.
- Parameters:
message- optional error messagetype- optional error type that is used byRetryOptions.Builder.setDoNotRetry(String...).details- optional details about the failure. They are serialized using the same approach as arguments and results.
-
newFailureWithCause
public static ApplicationFailure newFailureWithCause(String message, String type, @Nullable Throwable cause, Object... details) New ApplicationFailure withisNonRetryable()flag set to false.Note that this exception still may not be retried by the service if its type is included in the doNotRetry property of the correspondent retry policy.
- Parameters:
message- optional error messagetype- optional error type that is used byRetryOptions.Builder.setDoNotRetry(String...).cause- failure cause. Each element of the cause chain will be converted to ApplicationFailure for network transmission across network if it doesn't extendTemporalFailuredetails- optional details about the failure. They are serialized using the same approach as arguments and results.
-
newFailureWithCauseAndDelay
public static ApplicationFailure newFailureWithCauseAndDelay(String message, String type, @Nullable Throwable cause, Duration nextRetryDelay, Object... details) New ApplicationFailure withisNonRetryable()flag set to false.Note that this exception still may not be retried by the service if its type is included in the doNotRetry property of the correspondent retry policy.
- Parameters:
message- optional error messagetype- optional error type that is used byRetryOptions.Builder.setDoNotRetry(String...).cause- failure cause. Each element of the cause chain will be converted to ApplicationFailure for network transmission across network if it doesn't extendTemporalFailurenextRetryDelay- delay before the next retry attempt.details- optional details about the failure. They are serialized using the same approach as arguments and results.
-
newNonRetryableFailure
public static ApplicationFailure newNonRetryableFailure(String message, String type, Object... details) New ApplicationFailure withisNonRetryable()flag set to true.It means that this exception is not going to be retried even if it is not included into retry policy doNotRetry list.
- Parameters:
message- optional error messagetype- error typedetails- optional details about the failure. They are serialized using the same approach as arguments and results.
-
newNonRetryableFailureWithCause
public static ApplicationFailure newNonRetryableFailureWithCause(String message, String type, @Nullable Throwable cause, Object... details) New ApplicationFailure withisNonRetryable()flag set to true.This exception will not be retried even if it is absent from the retry policy doNotRetry list.
- Parameters:
message- optional error messagetype- error typecause- failure cause. Each element of the cause chain will be converted to ApplicationFailure for network transmission across network if it doesn't extendTemporalFailuredetails- optional details about the failure. They are serialized using the same approach as arguments and results.
-
getType
-
getDetails
-
getNextRetryDelay
-
setNonRetryable
public void setNonRetryable(boolean nonRetryable) -
isNonRetryable
public boolean isNonRetryable() -
setDataConverter
- Overrides:
setDataConverterin classTemporalFailure
-
setNextRetryDelay
-
getCategory
-