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:
parent
37b05f9d49
commit
9e67f27602
1 changed files with 7 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue