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 Type | Available |
---|---|
Generic logic | ✅ (handleError only) |
Aggregator logic | ✅ (handleError only) |
Import and Usage
The handleError
function in a logic receives a error
argument by default:
- JavaScript
- TypeScript
export async function run(ctx) {}
export async function handleError(ctx, error) {
// error is the railway error
}
import {
GenericContext,
RailwayError,
} from "@fstnetwork/loc-logic-sdk";
export async function run(ctx: GenericContext) {}
export async function handleError(ctx: GenericContext, error: RailwayError) {
// error is the railway error
}
Class Reference
Type
RailwayError
(extended fromError
)
Properties
Property | Type | Description |
---|---|---|
name | string | Error name |
message | string | Error message |
stack | string | Error stack trace message |
logicPermanentIdentity | string | Logic permanent ID where error originated |
logicRevision | number | Revision 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.