0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

fix(core): expose syntax error response (#6646)

expose syntax error response
This commit is contained in:
simeng-li 2024-10-08 10:14:21 +08:00 committed by GitHub
parent 37b05f9d49
commit 9e67f27602
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -44,6 +44,13 @@ export default function koaErrorHandler<StateT, ContextT, BodyT>(): Middleware<
return;
}
// Expose JSON body parsing errors
if (error instanceof SyntaxError) {
ctx.status = 400;
ctx.body = { message: error.message };
return;
}
// Should log 500 errors in prod anyway
if (EnvSet.values.isProduction) {
consoleLog.error(error);