Skip to content

Commit

Permalink
Merge pull request #987 from gettakaro/fix--catch-another-bad-json-error
Browse files Browse the repository at this point in the history
  • Loading branch information
niekcandaele authored Feb 11, 2024
2 parents 147ffea + 9fee51d commit c6b14fc
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/lib-http/src/middleware/errorHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ export async function ErrorHandler(

// If error is a JSON.parse error
if (originalError instanceof SyntaxError) {
if (originalError.message.includes('Unexpected token')) {
if (
originalError.message.includes('Unexpected token') ||
originalError.message.includes('Unexpected end of JSON input')
) {
status = 400;
parsedError = new errors.BadRequestError('Invalid JSON');
}
Expand Down

0 comments on commit c6b14fc

Please sign in to comment.