fix: return json error message when ?format=json (#16315)

This commit is contained in:
Songkeys
2024-07-31 19:14:20 +08:00
committed by GitHub
parent 66bcaa0c39
commit b0464552b4
+1 -1
View File
@@ -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,