Skip to content

Commit

Permalink
fix: return json error message when ?format=json (#16315)
Browse files Browse the repository at this point in the history
  • Loading branch information
songkeys authored Jul 31, 2024
1 parent 66bcaa0 commit b046455
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/errors/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const errorHandler: ErrorHandler = (error, ctx) => {
logger.error(`Error in ${requestPath}: ${message}`);
requestMetric.error({ path: requestPath, method: ctx.req.method, status: ctx.res.status });

return config.isPackage
return config.isPackage || ctx.req.query('format') === 'json'
? ctx.json({
error: {
message: error.message ?? error,
Expand Down

0 comments on commit b046455

Please sign in to comment.