useid / handlersjs

MIT License
3 stars 3 forks source link

feat: make JSON parsing more robust #199

Closed arnevandoorslaer closed 2 years ago

AbelVandenBriel commented 2 years ago

Updating this PR to limit it's scope to just JSON parsing.

I think the code included here to parse JSON bodies of response objects is good. I think what's currently missing is error handling when JSON parsing of requests (which will then be passed on to handlers further in the chain) needs to be handled better.

As detailed in #205, when sending incorrect JSON, this handler will error and return a 500 Internal Server Error.

We should devise a way to make it so we can easily distinguish what kind of error to throw, and only return a 500 Internal Server Error as a last resort.