Skip to content

Commit

Permalink
add validation error message
Browse files Browse the repository at this point in the history
  • Loading branch information
swain committed Jun 8, 2023
1 parent dc825b3 commit 8bfc07e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ export class OneSchemaRouter<
const result = await implementation(ctx);
const res = endpoint.response.safeParse(result);
if (!res.success) {
return ctx.throw(
500,
`A response value from endpoint '${route}' did not conform to the response schema.`,
);
const friendlyError = fromZodError(res.error, {
prefix: `A response value from endpoint '${route}' did not conform to the response schema.`,
});
return ctx.throw(500, friendlyError.message);
}
return res.data;
},
Expand Down

0 comments on commit 8bfc07e

Please sign in to comment.