Skip to main content

WorkflowError

workflow.WorkflowError is the standard error class used by the business workflow and runtime. It keeps the error type, node name, metadata, and cleaned cause, which eventually goes into the execution report.

Signature

new workflow.WorkflowError(options: WorkflowErrorOptions)

Parameter

ParameterTypeDescription
optionsWorkflowErrorOptionsStandard error configuration, including error type, message, node name, cause, and metadata.

WorkflowErrorOptions

FieldDescription
typeMisclassification. Required.
messageError messages visible to users and reports. Required.
nodeNameThe associated node name. runtime is replenished when node execution fails.
causeOriginal error. Only safe fields are preserved during serialization.
metadataDebuggable structured information.

WorkflowErrorType

TypeCommon SourcesDescription
input_validationParameter parsing, input node, file nodeInvalid input or missing configuration.
execution_abortedabort signal, timeout, execution restrictionsExecution was interrupted.
user_input_requiredUser input node, tool approvalworkflow Pause Wait to resume input.
tool_permission_deniedTool Permission Policy, Approval DenyThe current run does not allow the tool to be called.
node_executionNormal node execution failedAn unknown error thrown by a normal node.
provider_callLLM provider parse or callMissing provider, binding error, or call failure.
workflow_executionworkflow run failedworkflow Main process failed.
stream_interruptedstreaming node or provider streamStreaming output is interrupted or failed.

Instance field

FieldTypeDescription
name"WorkflowError"The Error name.
messagestringThe error message.
typeWorkflowErrorTypeMisclassification.
nodeNamestring | undefinedThe associated node.
metadataobject | undefinedAdditional debugging information.
safeCauseWorkflowErrorCause | undefinedcause after cleaning.

serialization structure

FieldTypeDescription
typeWorkflowErrorTypeMisclassification.
messagestringThe error message.
nodeNamestring | undefinedThe associated node.
metadataobject | undefinedAdditional information.
causeWorkflowErrorCause | undefinedKeep only the safe cause field.

Error Code Mapping

Running the report maps the failure type to payload errCode.

Error TypeerrCode
input_validation400
user_input_required202
tool_permission_denied403
execution_aborted499
stream_interrupted499
provider_call502
node_execution500
workflow_execution500

Example

throw new workflow.WorkflowError({
type: "input_validation",
message: "message is required.",
nodeName: "parse-input",
metadata: {
field: "message",
},
});

When to use

SceneRecommendation
Illegal user inputThrow input_validation.
External service call failedThrow provider_call or let the provider layer wrap.
Want the report to retain structured contextUse metadata.
Common Unknown ExceptionCan be thrown directly,runtime will be wrapped as WorkflowError.