Skip to content

Add name property to custom error classes #471

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading