Skip to content

Commit

Permalink
Make invalid schema message more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
gloooor committed Sep 7, 2021
1 parent 2448993 commit d0ee993
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/config/koa.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ const routeErrorHandler = async (ctx, next) => {
ctx.status = error.statusCode || error.status || 500;

if (!ctx.body) {
const errorDetails = error.message.match('details":\\[(.*)\\]}');

ctx.body = {
errors: {
_global: [error.message],
_global: errorDetails ? [JSON.parse(errorDetails[1])] : [error.message],
},
};
}
Expand Down

0 comments on commit d0ee993

Please sign in to comment.