Skip to content

Commit

Permalink
fix: errorHandler properly catch errors
Browse files Browse the repository at this point in the history
  • Loading branch information
neurosnap committed Jul 30, 2023
1 parent cdc5721 commit 25ec8ea
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions query/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ export function* errorHandler<Ctx extends PipeCtx = PipeCtx>(
ctx: Ctx,
next: Next,
) {
try {
yield* next();
} catch (err) {
yield* next();

if (!ctx.result.ok) {
console.error(
`Error: ${err.message}. Check the endpoint [${ctx.name}]`,
`Error: ${ctx.result.error.message}. Check the endpoint [${ctx.name}]`,
ctx,
);
throw err;
console.error(ctx.result.error);
}
}

Expand Down

0 comments on commit 25ec8ea

Please sign in to comment.