Share via


FailureDetails Class

  • java.lang.Object
    • com.microsoft.durabletask.FailureDetails

public final class FailureDetails

Class that represents the details of a task failure.

In most cases, failures are caused by unhandled exceptions in activity or orchestrator code, in which case instances of this class will expose the details of the exception. However, it's also possible that other types of errors could result in task failures, in which case there may not be any exception-specific information.

Method Summary

Modifier and Type Method and Description
java.lang.String getErrorMessage()

Gets a summary description of the error that caused this failure.

java.lang.String getErrorType()

Gets the exception class name if the failure was caused by an unhandled exception.

java.lang.String getStackTrace()

Gets the stack trace of the exception that caused this failure, or null if the failure was caused by a non-exception error.

boolean isCausedBy(Class<? extends Exception> exceptionClass)

Returns true if the task failure was provided by the specified exception type, otherwise false.

boolean isNonRetriable()

Returns true if the failure doesn't permit retries, otherwise false.

Methods inherited from java.lang.Object

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.toString java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

Method Details

getErrorMessage

public String getErrorMessage()

Gets a summary description of the error that caused this failure. If the failure was caused by an exception, the exception message is returned.

Returns:

a summary description of the error

getErrorType

public String getErrorType()

Gets the exception class name if the failure was caused by an unhandled exception. Otherwise, gets a symbolic name that describes the general type of error that was encountered.

Returns:

the error type as a String value

getStackTrace

public String getStackTrace()

Gets the stack trace of the exception that caused this failure, or null if the failure was caused by a non-exception error.

Returns:

the stack trace of the failure exception or null if the failure was not caused by an exception

isCausedBy

public boolean isCausedBy(Class exceptionClass)

Returns true if the task failure was provided by the specified exception type, otherwise false.

This method allows checking if a task failed due to a specific exception type by attempting to load the class specified in getErrorType(). If the exception class cannot be loaded for any reason, this method will return false. Base types are supported by this method, as shown in the following example:

boolean isRuntimeException = failureDetails.isCausedBy(RuntimeException.class);

Parameters:

exceptionClass - the class representing the exception type to test

Returns:

true if the task failure was provided by the specified exception type, otherwise false

isNonRetriable

public boolean isNonRetriable()

Returns true if the failure doesn't permit retries, otherwise false.

Returns:

true if the failure doesn't permit retries, otherwise false.

Applies to