Class: ApplicationFailure
common.ApplicationFailure
ApplicationFailures are used to communicate application-specific failures in Workflows and Activities.
The type property is matched against RetryPolicy.nonRetryableErrorTypes to determine if an instance
of this error is retryable. Another way to avoid retrying is by setting the nonRetryable flag to true.
In Workflows, if you throw a non-ApplicationFailure, the Workflow Task will fail and be retried. If you throw an
ApplicationFailure, the Workflow Execution will fail.
In Activities, you can either throw an ApplicationFailure or another Error to fail the Activity Task. In the
latter case, the Error will be converted to an ApplicationFailure. The conversion is done as following:
typeis set toerror.constructor?.name ?? error.namemessageis set toerror.messagenonRetryableis set to falsedetailsare set to null- stack trace is copied from the original error
When an Activity Execution fails, the
ApplicationFailure from the last Activity Task will be the cause of the ActivityFailure thrown in the
Workflow.
Hierarchy
-
↳
ApplicationFailure
Constructors
constructor
• new ApplicationFailure(message?, type?, nonRetryable?, details?, cause?, nextRetryDelay?, category?): ApplicationFailure
Alternatively, use fromError or create.
Parameters
| Name | Type |
|---|---|
message? | null | string |
type? | null | string |
nonRetryable? | null | boolean |
details? | null | unknown[] |
cause? | Error |
nextRetryDelay? | null | Duration |
category? | null | "BENIGN" |
Returns
Overrides
Properties
category
• Optional Readonly category: null | "BENIGN"
cause
• Optional Readonly cause: Error
Inherited from
details
• Optional Readonly details: null | 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
message
• message: string
Inherited from
name
• name: string
Inherited from
nextRetryDelay
• Optional Readonly nextRetryDelay: null | Duration
nonRetryable
• Optional Readonly nonRetryable: null | boolean
stack
• Optional stack: string
Inherited from
type
• Optional Readonly type: null | string
prepareStackTrace
▪ Static Optional prepareStackTrace: (err: Error, stackTraces: CallSite[]) => any
Optional override for formatting stack traces
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Type declaration
▸ (err, stackTraces): any
Optional override for formatting stack traces
Parameters
| Name | Type |
|---|---|
err | Error |
stackTraces | CallSite[] |
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Inherited from
TemporalFailure.prepareStackTrace
stackTraceLimit
▪ Static stackTraceLimit: number
Inherited from
TemporalFailure.stackTraceLimit
Methods
captureStackTrace
▸ captureStackTrace(targetObject, constructorOpt?): void
Create .stack property on a target object
Parameters
| Name | Type |
|---|---|
targetObject | object |
constructorOpt? | Function |
Returns
void
Inherited from
TemporalFailure.captureStackTrace
create
▸ create(options): ApplicationFailure
Create a new ApplicationFailure.
By default, will be retryable (unless its type is included in RetryPolicy.nonRetryableErrorTypes).
Parameters
| Name | Type |
|---|---|
options | ApplicationFailureOptions |
Returns
fromError
▸ fromError(error, overrides?): ApplicationFailure
Create a new ApplicationFailure from an Error object.
First calls ensureApplicationFailure(error) and then overrides any fields
provided in overrides.
Parameters
| Name | Type |
|---|---|
error | unknown |
overrides? | ApplicationFailureOptions |
Returns
nonRetryable
▸ nonRetryable(message?, type?, ...details): ApplicationFailure
Get a new ApplicationFailure with the nonRetryable flag set to true.
When thrown from an Activity or Workflow, the Activity or Workflow will not be retried (even if type is not
listed in RetryPolicy.nonRetryableErrorTypes).
Parameters
| Name | Type | Description |
|---|---|---|
message? | null | string | Optional error message |
type? | null | string | Optional error type |
...details | unknown[] | Optional details about the failure. Serialized by the Worker's PayloadConverter. |
Returns
retryable
▸ retryable(message?, type?, ...details): ApplicationFailure
Get a new ApplicationFailure with the nonRetryable flag set to false. Note that this error will still
not be retried if its type is included in RetryPolicy.nonRetryableErrorTypes.
Parameters
| Name | Type | Description |
|---|---|---|
message? | null | string | Optional error message |
type? | null | string | Optional error type (used by RetryPolicy.nonRetryableErrorTypes) |
...details | unknown[] | Optional details about the failure. Serialized by the Worker's PayloadConverter. |