Class ApplicationFailure
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- io.temporal.failure.TemporalException
-
- io.temporal.failure.TemporalFailure
-
- io.temporal.failure.ApplicationFailure
-
- All Implemented Interfaces:
java.io.Serializable
public final class ApplicationFailure extends TemporalFailure
Application failure is used to communicate application specific failures between workflows and activities.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
TemporalFailureis converted to an instance of this class before being returned to a caller.The
typeproperty is used byRetryOptionsto determine if an instance of this exception is non retryable. Another way to avoid retrying an exception of this type is by settingnonRetryableflag to @{code true}.The conversion of an exception that doesn't extend
TemporalFailureto 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
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ValuesgetDetails()java.time.DurationgetNextRetryDelay()java.lang.StringgetType()booleanisNonRetryable()static ApplicationFailurenewFailure(java.lang.String message, java.lang.String type, java.lang.Object... details)New ApplicationFailure withisNonRetryable()flag set to false.static ApplicationFailurenewFailureWithCause(java.lang.String message, java.lang.String type, java.lang.Throwable cause, java.lang.Object... details)New ApplicationFailure withisNonRetryable()flag set to false.static ApplicationFailurenewFailureWithCauseAndDelay(java.lang.String message, java.lang.String type, java.lang.Throwable cause, java.time.Duration nextRetryDelay, java.lang.Object... details)New ApplicationFailure withisNonRetryable()flag set to false.static ApplicationFailurenewNonRetryableFailure(java.lang.String message, java.lang.String type, java.lang.Object... details)New ApplicationFailure withisNonRetryable()flag set to true.static ApplicationFailurenewNonRetryableFailureWithCause(java.lang.String message, java.lang.String type, java.lang.Throwable cause, java.lang.Object... details)New ApplicationFailure withisNonRetryable()flag set to true.voidsetDataConverter(DataConverter converter)voidsetNextRetryDelay(java.time.Duration nextRetryDelay)voidsetNonRetryable(boolean nonRetryable)-
Methods inherited from class io.temporal.failure.TemporalFailure
getOriginalMessage
-
-
-
-
Method Detail
-
newFailure
public static ApplicationFailure newFailure(java.lang.String message, java.lang.String type, java.lang.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...).details- optional details about the failure. They are serialized using the same approach as arguments and results.
-
newFailureWithCause
public static ApplicationFailure newFailureWithCause(java.lang.String message, java.lang.String type, @Nullable java.lang.Throwable cause, java.lang.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...).details- optional details about the failure. They are serialized using the same approach as arguments and results.cause- failure cause. Each element of the cause chain will be converted to ApplicationFailure for network transmission across network if it doesn't extendTemporalFailure
-
newFailureWithCauseAndDelay
public static ApplicationFailure newFailureWithCauseAndDelay(java.lang.String message, java.lang.String type, @Nullable java.lang.Throwable cause, java.time.Duration nextRetryDelay, java.lang.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...).details- optional details about the failure. They are serialized using the same approach as arguments and results.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.
-
newNonRetryableFailure
public static ApplicationFailure newNonRetryableFailure(java.lang.String message, java.lang.String type, java.lang.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(java.lang.String message, java.lang.String type, @Nullable java.lang.Throwable cause, java.lang.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 typedetails- optional details about the failure. They are serialized using the same approach as arguments and results.cause- failure cause. Each element of the cause chain will be converted to ApplicationFailure for network transmission across network if it doesn't extendTemporalFailure
-
getType
public java.lang.String getType()
-
getDetails
public Values getDetails()
-
getNextRetryDelay
@Nullable public java.time.Duration getNextRetryDelay()
-
setNonRetryable
public void setNonRetryable(boolean nonRetryable)
-
isNonRetryable
public boolean isNonRetryable()
-
setDataConverter
public void setDataConverter(DataConverter converter)
- Overrides:
setDataConverterin classTemporalFailure
-
setNextRetryDelay
public void setNextRetryDelay(java.time.Duration nextRetryDelay)
-
-