我怎么能知道,如果在PhoneGap的应用程序中发生JavaScript异常? (安卓) [英] How can I know if a Javascript exception occurred in a PhoneGap application? (Android)

查看:113
本文介绍了我怎么能知道,如果在PhoneGap的应用程序中发生JavaScript异常? (安卓)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么能知道,如果在PhoneGap的应用程序中发生JavaScript异常?

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

我使用的HTC Desire Z和Android 2.2的。

I'm using HTC Desire Z and Android 2.2.

我看不出有任何的logcat和jsconsole.com似乎不支持异常传输。

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

使用的console.log到Trac的每一个例外是有点难。是否有一个解决方案,或者这只是它是如何与PhoneGap的?

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?

编辑:这似乎是可以捕获至少一些与一些真的哈克包装的异常。这有时可以让你在正确的轨道,但可能有一些严重的副作用,也不会肯定捕获所有异常。

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.

推荐答案

未捕获的异常应该出现在logcat中 - 至少在消息和行号

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

否则,你没有太多的选择。 window.onerror不能在Android的AFAIK工作。

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

这篇关于我怎么能知道,如果在PhoneGap的应用程序中发生JavaScript异常? (安卓)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆