Quantcast
Viewing all articles
Browse latest Browse all 8068

Catching Exceptions

Is there a link, article, or section of the docs that describes best practices for catching exceptions by, I assume, the use of try/catch/finally?

I am noticing that, in many cases, the entire application will crash when it encounters errors even if enclosed in a try/catch.

For example, this common and simple scenario of parsing JSON will cause the app to crash:

var myJson = null;
try {
    myJson = JSON.parse('not JSON');
} catch (err) {
    alert('cant convert to json: ' + err.message);
    return;         
}
When executing this code, the application crashes at myJson = JSON.parse('not JSON') and the catch is never executed.

I have seen similar complaints in other posts

http://developer.appcelerator.com/question/137568/silent-errors-in-201-ga2- http://developer.appcelerator.com/question/130582/how-to-catch-errors http://developer.appcelerator.com/question/57911/trycatch-not-catching-errors

go unanswered.

I am using version 3.1.3 with Android 4.2 running on a device.


Viewing all articles
Browse latest Browse all 8068

Trending Articles