Skip to content

Commit

Permalink
feat: add NonRetryableError
Browse files Browse the repository at this point in the history
  • Loading branch information
LuisDuarte1 committed Aug 30, 2024
1 parent 8b8f52d commit 3fe32c6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/cloudflare/internal/workflows-api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

export class NonRetryableError extends Error {
// `__brand` is needed for Workflows' engine to validate if the user returned a NonRetryableError
// this provides better DX because they can just extend NonRetryableError for their own Errors
public readonly __brand: string = "NonRetryableError"

public constructor(message: string, name = "NonRetryableError") {
super(message);
this.name = name;
}
}

1 change: 1 addition & 0 deletions src/cloudflare/workflows.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { NonRetryableError } from "cloudflare-internal:workflows-api"
8 changes: 8 additions & 0 deletions types/defines/workflows.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

/**
* NonRetryableError allows for a Workflow to throw a "fatal" error as in,
* an error that makes the instance fail immediately without triggering a retry.
*/
export class NonRetryableError extends Error {
public constructor(message: string, name?: string);
}

0 comments on commit 3fe32c6

Please sign in to comment.