Runlane
ReferenceApplication API

Errors

Construct Runlane errors, control retries, and read stored failures.

Import ErrorCode and RunlaneError from @runlane/core.

Construct an error

Use RunlaneError when a task needs to state whether a failure can be retried:

import { ErrorCode, RunlaneError } from '@runlane/core'

throw new RunlaneError({
  code: ErrorCode.TaskFailed,
  message: 'The account no longer exists.',
  retryable: false,
  meta: { reason: 'account_deleted' },
})

The constructor accepts RunlaneErrorOptions:

FieldType and default
codeRequired ErrorCode.
messageOptional string. Defaults to the code.
retryableOptional boolean. Defaults to false.
causeOptional original thrown value, kept for internal diagnosis.
metaOptional JsonObject with safe, structured context.

The instance extends Error and exposes these fields. Use error instanceof RunlaneError before reading them. Match error.code, not message text. If you catch another kind of error, treat it as an unexpected application or dependency failure.

Thrown errors and stored failures

Public operations such as trigger() reject when setup, validation, storage, or delivery fails. Catch those errors around the API call.

Handler failures are normally saved on the run. runNow() executes one attempt and returns a RunRecord; a failed handler does not normally make that call reject. Check the returned run's status and failure, or read the run later through runlane.runs.get().

A stored RunFailure has code, message, retryable, and optional meta. Runlane uses a stable public message for the code. It does not store the original stack, cause, or custom error message in that failure record. Put safe details needed by operators in meta; keep secrets and raw provider responses out of it.

Retry decisions

Handler resultAutomatic retry behavior
Ordinary thrown Error, with a task retry policyRetryable while the attempt count is below maxAttempts.
RunlaneError with retryable: trueRetryable only if the task also has a retry policy and budget remains.
RunlaneError with retryable: false or no retryable fieldEnds as failed without automatic retry.
Any failure with no task retry policyNo automatic retry.
Attempt deadline expiresRecords TaskTimedOut. Retries if the task policy allows another attempt; otherwise ends as failed.
Returned release or waitEnds the attempt without recording a failure. Resumed attempts still count toward later retry decisions.

Mark a failure retryable only if repeating the work can help. The retry guide shows both temporary and permanent failures in one task.

Error codes

These members belong to ErrorCode. Their stored values use snake case.

MemberStored valueMeaning
AdapterContractViolationadapter_contract_violationAn adapter returned data or behavior outside its contract.
CapabilityUnsupportedcapability_unsupportedThe configured lane or provider does not support the operation.
ConfigurationInvalidconfiguration_invalidA definition or option is invalid.
InternalErrorinternal_errorAn internal operation failed.
InvariantViolationinvariant_violationStored or runtime state violates a required rule.
OperationCancelledoperation_cancelledAn operation was cancelled.
ObservationExportFailedobservation_export_failedExporting observations failed.
RunNotFoundrun_not_foundAn operation requires a run that does not exist. A plain runs.get() returns undefined instead.
ScheduleNotFoundschedule_not_foundA required schedule was not found.
StorageConflictstorage_conflictA concurrent write or ownership claim conflicted.
StorageUnavailablestorage_unavailableStorage could not serve the operation.
TaskFailedtask_failedThe task handler failed.
TaskNotFoundtask_not_foundThe runtime cannot find the task definition.
TaskOutputInvalidtask_output_invalidTask output does not match its schema or storage format.
TaskTimedOuttask_timed_outThe attempt exceeded its time limit.
TransportPublishFailedtransport_publish_failedPublishing a delivery request failed.
TransportUnavailabletransport_unavailableThe delivery service is unavailable.
ValidationFailedvalidation_failedA payload or other operation input failed validation.
WaitTokenNotFoundwait_token_not_foundAn operation requires a missing wait token. A plain token read returns undefined instead.
WaitTokenOutputInvalidwait_token_output_invalidA completed token's output does not match the requested schema.

Use the error's retryable field and the operation's state to decide what to do next. An error code alone is not a promise that retrying is safe.

On this page