4

How can I know if a Javascript exception occurred in a PhoneGap application?

I'm using HTC Desire Z and Android 2.2.

I don't see anything in logcat and jsconsole.com does not seem to support exception transporting.

Using console.log to trac every exception is bit hard. Is there a solution for this or is this just how it is with Phonegap?

EDIT: It seems to be possible to capture at least some of exceptions with some really hacky wrappers. This some times can put you on the right track, but probably has some serious side effects and it won't certainly capture all the exceptions.

0

3 Answers 3

2

Uncaught exceptions should show up in logcat - at least the message and line number.

Otherwise you don't have many options. window.onerror does not work in Android AFAIK.

1
0

From a recent post from the PhoneGap blog:

It’s a mobile browser! How am I supposed to debug it! The answer is that you aren’t. You are going to debug your HTML, CSS, and JavaScript app in a desktop browser. The trick is to remove any dependencies that you have on PhoneGap before debugging.

http://www.phonegap.com/2011/05/18/debugging-phonegap-javascript/

Only if the desktop browser would work exactly like the mobile one...

1
  • 1
    this is not an answer
    – DATEx2
    Sep 4, 2013 at 21:25
0

Is your question about logging the exceptions or about debugging them during development?

I'm not sure about the best way of logging them, but to debug them you can use Weinre.

I just wrote about Weinre on another very similar question ( https://stackoverflow.com/a/9252262/172973 )

Basically it's a remote javascript debugger for phonegap. You can either setup your own Weinre server, or use the one at http://debug.phonegap.com/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.