Skip to content
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

Error hooks - re-throwing vs assigning context.error #105

Closed
KidkArolis opened this issue Jan 27, 2023 · 0 comments · Fixed by #107
Closed

Error hooks - re-throwing vs assigning context.error #105

KidkArolis opened this issue Jan 27, 2023 · 0 comments · Fixed by #107

Comments

@KidkArolis
Copy link

The behaviour of throwing in an error hook changed slightly from V4->V5.

If an error hook modifies context.error - that's all fine, the context is now updated and the error is re-thrown in regular.ts.
But if an error hook throws an error, that does not update context.error like it used to.

Perhaps this here should .catch(error => { context.error = error; throw context.error })

return runHook(hook, context, 'error').then(() => {
if (context.result === undefined && context.error !== undefined) {
throw context.error;
}
});
?

@KidkArolis KidkArolis changed the title Error hook throwing Error hooks - re-throwing vs assigning context.error Jan 30, 2023
@daffl daffl closed this as completed in #107 Feb 7, 2023
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 a pull request may close this issue.

1 participant