Using node/express -
I want to get some JSON out of request headers, but I want to do it safely.
If for some reason it's not valid JSON, it's fine, it can just return false or whatever and it will just reject the request and keep going. The problem is it throws a syntax error if it's not valid JSON. Normally I want a syntax error to blow up, but not in this case.
var boom = JSON.parse(req.headers.myHeader);
Do I scrape the stack and check for a bad parse call from that particular module, and if it's the case, it ignores it? That seems a bit crazy. Surely there's a better way.
EDIT:
I am aware that try/catch blocks are A way of handling this error, but is it the best way in a node app? Will this way block node?