Skip to content

Commit

Permalink
add names to custom error classes (#471)
Browse files Browse the repository at this point in the history
  • Loading branch information
rashfael authored Dec 20, 2024
1 parent 93eebb6 commit 0eff045
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/restate-sdk/src/types/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export function ensureError(e: unknown): Error {

export class RestateError extends Error {
public readonly code: number;
public name = "RestateError";

constructor(message: string, options?: { errorCode?: number; cause?: any }) {
super(message, { cause: options?.cause });
Expand All @@ -51,12 +52,16 @@ export class RestateError extends Error {
// Does not lead to Restate retries
// Leads to an output message with a failure defined
export class TerminalError extends RestateError {
public name = "TerminalError";

constructor(message: string, options?: { errorCode?: number; cause?: any }) {
super(message, options);
}
}

export class TimeoutError extends TerminalError {
public name = "TimeoutError";

constructor() {
super("Timeout occurred", { errorCode: TIMEOUT_ERROR_CODE });
}
Expand Down

0 comments on commit 0eff045

Please sign in to comment.