public final class ApplicationFailure extends TemporalFailure
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:
Modifier and Type | Method and Description |
---|---|
Values |
getDetails() |
java.lang.String |
getType() |
boolean |
isNonRetryable() |
static ApplicationFailure |
newFailure(java.lang.String message,
java.lang.String type,
java.lang.Object... details)
New ApplicationFailure with
isNonRetryable() flag set to false. |
static ApplicationFailure |
newNonRetryableFailure(java.lang.String message,
java.lang.String type,
java.lang.Object... details)
New ApplicationFailure with
isNonRetryable() flag set to true. |
void |
setDataConverter(DataConverter converter) |
void |
setNonRetryable(boolean nonRetryable) |
getOriginalMessage
public static ApplicationFailure newFailure(java.lang.String message, java.lang.String type, java.lang.Object... details)
isNonRetryable()
flag set to false. Note that this
exception still can be not retried by the service if its type is included into doNotRetry
property of the correspondent retry policy.message
- optional error messagetype
- optional error type that is used by RetryOptions.Builder.setDoNotRetry(String...)
.details
- optional details about the failure. They are serialized using the same approach
as arguments and results.public static ApplicationFailure newNonRetryableFailure(java.lang.String message, java.lang.String type, java.lang.Object... details)
isNonRetryable()
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.
message
- optional error messagetype
- optional error typedetails
- optional details about the failure. They are serialized using the same approach
as arguments and results.public java.lang.String getType()
public Values getDetails()
public void setNonRetryable(boolean nonRetryable)
public boolean isNonRetryable()
public void setDataConverter(DataConverter converter)
setDataConverter
in class TemporalFailure