Defines discriminated custom error classes for the task engine, covering not‑found, invalid transitions, version conflicts, and unknown fields, enabling precise error handling and retry logic.
// Source: https://github.com/FarzamMohammadi/the-engineer | License: MIT | Copyright 2026 Farzam Mohammadi
// Provided via justclaw.it.com; keep this notice with the code.
/** Base class for all task-engine errors. Tagged for discriminated matching. */
export abstract class TaskEngineError extends Error {
abstract readonly tag: string;
abstract readonly retryable: boolean;
}
/** Task was not found by ID. */
export class TaskNotFoundError extends TaskEngineError {
readonly tag = "TaskNotFound" as const;
readonly retryable = false;
readonly taskId: string;
constructor(taskId: string) {
super(`Task "${taskId}" not found`);
this.name = "TaskNotFoundError";
this.taskId = taskId;
}
}
/** State transition is not valid per the state machine. */
export class InvalidTra
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key