Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Try/Catch not Catching Errors

I had a try/catch block surrounding some code but was still getting a force close so I tried the following test:

try {
    var a = new Array(1111222223333444456789);
} catch (err) {

This code works in a browser (replacing Ti.API.error with alert) but still causes a force close in Titanium mobile under Android.

Any ideas?

— asked September 2nd 2010 by Andrew Barilla
  • catch
  • error
  • handling
  • try
  • I get the same thing, anywhere I wrap questionable code with a try/catch on Android, it still force closes or throws a different type of error. Any progress on this?

    — commented May 22nd 2011 by Shane Sievers
  • Is there a solution for this? I'm having huge trouble doing JSON.parse safely, as the input format isn't always "good". Since JSON.parse doesn't have any options for callbacks, I'm relying on Try/Catch

    — commented June 16th 2014 by Fabian Tollenaar

1 Answer

  • Would like to know about this as well, try / catch isn't working for me, at all.

    — answered July 20th 2011 by Benjamin Sommerfeld
    • @Ben S, I am curious as to why you chose to answer this question with an uninformative statement. Would your comment be a better fit for a comment on @Andrews question?

      — commented July 20th 2011 by Shane Sievers
    • Sorry I just used the wrong button / function to answer. Should've posted a comment, you're right.

      — commented July 20th 2011 by Benjamin Sommerfeld
    • I'm an avid stackoverflow user and I guess that gets hammered into you pretty quick on those sites. It is frustrating to look through this area for answers and see that they are all just comments back and forth. Thank you for keeping an eye on that.

      — commented July 20th 2011 by Shane Sievers
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.