Skip to main content

Class: ApplicationFailure

client.ApplicationFailure

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 TemporalFailure is converted to an instance of this class before being returned to a caller.

The type property is used by {@link temporal.common.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 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

Hierarchy

Constructors

constructor

new ApplicationFailure(message, type, nonRetryable, details?, cause?)

Parameters

NameType
messageundefined | string
typeundefined | null | string
nonRetryableboolean
details?unknown[]
cause?Error

Overrides

TemporalFailure.constructor

Properties

cause

Optional Readonly cause: Error

Inherited from

TemporalFailure.cause


details

Optional Readonly details: unknown[]


failure

Optional failure: IFailure

The original failure that constructed this error.

Only present if this error was generated from an external operation.

Inherited from

TemporalFailure.failure


message

message: string

Inherited from

TemporalFailure.message


name

Readonly name: string

Overrides

TemporalFailure.name


nonRetryable

Readonly nonRetryable: boolean


stack

Optional stack: string

Inherited from

TemporalFailure.stack


type

Readonly type: undefined | null | string


prepareStackTrace

Static Optional prepareStackTrace: (err: Error, stackTraces: CallSite[]) => any

Optional override for formatting stack traces

Type declaration

▸ (err, stackTraces): any

Optional override for formatting stack traces

see https://v8.dev/docs/stack-trace-api#customizing-stack-traces

Parameters
NameType
errError
stackTracesCallSite[]
Returns

any

Inherited from

TemporalFailure.prepareStackTrace


stackTraceLimit

Static stackTraceLimit: number

Inherited from

TemporalFailure.stackTraceLimit

Methods

captureStackTrace

Static captureStackTrace(targetObject, constructorOpt?): void

Create .stack property on a target object

Parameters

NameType
targetObjectobject
constructorOpt?Function

Returns

void

Inherited from

TemporalFailure.captureStackTrace


nonRetryable

Static nonRetryable(message, type?, ...details): ApplicationFailure

New ApplicationFailure with nonRetryable 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

NameTypeDescription
messageundefined | stringoptional error message
type?stringoptional error type
...detailsunknown[]optional details about the failure. They are serialized using the same approach as arguments and results.

Returns

ApplicationFailure


retryable

Static retryable(message, type?, ...details): ApplicationFailure

New ApplicationFailure with nonRetryable 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.

Parameters

NameTypeDescription
messageundefined | stringoptional error message
type?stringoptional error type that is used by {@link RetryOptions.nonRetryableErrorTypes}.
...detailsunknown[]optional details about the failure. They are serialized using the same approach as arguments and results.

Returns

ApplicationFailure