Javascript try catch with json parse

I have several json objects that come from the server. At the moment I am using json functions for browsers (my application only supports modern browsers) to parse json for objects.

Should I use try / catch to make my application more robust or use try / catch to create a different set of problems?

+3
source share
3 answers

try..catch is not a magic design to keep problems from disappearing. The question is, what would you put in your catch {} clause?

If you can do something useful, if json is broken. Something that allows you to make sure that the state of the application has returned again, then it makes sense.

, json? json, .

+5

try / catch - , 100% , .

, , JSON, try / catch.

, json2.js , JSON .

+2

SERVER, .
, ( )

, .

+1

All Articles