Skip to main content

Logic Error - JS/TS

If an unhandled error had been thrown in the task, an error object would be passed to the logic and all subsequential ones. The object is called a Railway Error.

Logic TypeAvailable
Generic logic✅ (handleError only)
Aggregator logic✅ (handleError only)

Import and Usage​

The handleError function in a logic receives a error argument by default:

export async function run(ctx) {}

export async function handleError(ctx, error) {
// error is the railway error
}

Class Reference​

Type​

  • RailwayError (extended from Error)

Properties​

PropertyTypeDescription
namestringError name
messagestringError message
stackstringError stack trace message
logicPermanentIdentitystringLogic permanent ID where error originated
logicRevisionnumberRevision of the logic where error originated

Error​

Refer to: Error

Examples​

Get Error​

handleError()
const errorPid = error.logicPermanentIdentity;

const errorMessage = error.message;

const errorStack = error.stack;

Throw Error​

throw new Error("oh no, not again.");

The error will be packaged as RailwayError by LOC runtime.