From b0464552b460f162ed9629dd7f70c0f7d94feba9 Mon Sep 17 00:00:00 2001 From: Songkeys Date: Wed, 31 Jul 2024 19:14:20 +0800 Subject: [PATCH] fix: return json error message when ?format=json (#16315) --- lib/errors/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/errors/index.tsx b/lib/errors/index.tsx index 24a15ad57..65353af1e 100644 --- a/lib/errors/index.tsx +++ b/lib/errors/index.tsx @@ -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,