I want to catch the error from the bodyParser() middleware when I send a json object and it is invalid because I want to send a custom response instead of a generic 400 erro
I found checking for SyntaxError to be not enough, therefore I do:
SyntaxError
if (err instanceof SyntaxError && err.status >= 400 && err.status < 500 && err.message.indexOf('JSON') !== -1) { // process filtered exception here }