Skip to content
This repository has been archived by the owner on Oct 11, 2022. It is now read-only.

handling error for invalid JSON in the request body #145

Open
KapilGahlot opened this issue Nov 3, 2017 · 0 comments
Open

handling error for invalid JSON in the request body #145

KapilGahlot opened this issue Nov 3, 2017 · 0 comments

Comments

@KapilGahlot
Copy link

I have issues similar to #82 . I am using the error middleware JsonRoutes.ErrorMiddleware.use(RestMiddleware.handleErrorAsJson) but if the JSON in the request body is not valid such as containing unescaped newline chars, I get response with code 500 and not so good looking text on the lines of "Meteor code must always run within a Fiber". I believe this is reproducible with any post request with invalid JSON body. The error message points to body-parser as seen below:

SyntaxError: Unexpected token

at Object.parse (native)

\.meteor\packages\simple_json-routes\2.1.0\npm\node_modules\connect\node_modules
\body-parser\lib\types\json.js:88:17

Please can this be handled in a better way?

Thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant