Skip to content

Improve error handling and update exports (breaking change)#36

Merged
ecraig12345 merged 1 commit intomainfrom
ecraig/v2
Feb 19, 2026
Merged

Improve error handling and update exports (breaking change)#36
ecraig12345 merged 1 commit intomainfrom
ecraig/v2

Conversation

@ecraig12345
Copy link
Member

Previously, with continue: true, PGraph would throw an array of errors. Throwing non-Error things is not recommended, and it was especially confusing since what was thrown could vary based on options.

This PR introduces a new class PGraphError which has a message summarizing the other errors, and has a property taskErrors: unknown[] with the original errors. A PGraphError is now thrown any time a task fails, regardless of the continue option. (A regular Error could also be thrown if there's an initial validation error.)

Since this is already a breaking change, I decided to also remove the default export function and remove the pGraph wrapper function. Instead, just import PGraph then do new PGraph().

One other new nice-to-have feature is that the task-level run function is now optional, and PGraph.run() has a new option run?: (taskId: string) => unknown to run a shared function for each task. This makes it possible to reuse the same PGraph initialization to run multiple functions, since calculating the graph could get somewhat expensive if there are many tasks.

@ecraig12345 ecraig12345 merged commit 5372ec0 into main Feb 19, 2026
5 checks passed
@ecraig12345 ecraig12345 deleted the ecraig/v2 branch February 19, 2026 06:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant