一个可以捕捉钛中所有突发异常的地方吗? [英] one place to catch all sudden exceptions in titanium?

本文介绍了一个可以捕捉钛中所有突发异常的地方吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Titanium Android应用程序开发的新手,在使用我的应用程序时遇到了网络中断"的令人不愉快的情况. 我尝试在模拟器上重现它,但是在应用程序仍然运行时进入飞行模式".

I am new to Titanium Android App development and going through an unpleasant scenario of "Network goes off" during use of my app. I tried reproducing it on my emulator, but going "Airplane mode" while app still working.

我在以下app.js中尝试过:

I tried below in app.js:

Ti.App.addEventListener('uncaughtException',function(){
alert("caught"); });  

Ti.App.addEventListener('TiException',function(){
alert("caught:Ti"); });

很好的是,我能够看到抓到",但在我的应用程序看到红色的屏幕细节并坏了之前看不到.见图片: 应用程序崩溃错误

So good thing is I am able to see "caught" but not before my app sees a red screen detailing and it breaks. see image: App crash error

如果有人可以帮助我确定如何捕获所有这些计划外"异常,并按照某些业务逻辑对其进行指导,以使用户看不到这些爆炸,这将非常有帮助.

it would be very helpful if someone can help me out in identifying how to catch all those 'unplanned' exceptions and direct them as per some business logic so that user doesnot see those blasts.

预先感谢

推荐答案

您看到的异常与LiveView有关.在此处查看文档: http://docs.appcelerator.com/platform/最新的/#!/guide/LiveView ,它与应用程序上的代码完全无关.

The exception that you are seeing is related to LiveView. See the docs here: http://docs.appcelerator.com/platform/latest/#!/guide/LiveView which is totally unrelated to the code on the app.

如果要在应用程序中测试脱机模式,则需要在不使用LiveView的情况下运行它,因为它需要连接才能正常工作.

If you are going to test offline mode in your app you need to run it without LiveView because it requires connectivity to work.

供参考:

捕获所有异常的事件是 uncaughtException

The event that catches all the exceptions is uncaughtException

TiException不是有效的事件,因此它将永远不会被触发.

TiException is not a valid event so it will never be triggered.

这篇关于一个可以捕捉钛中所有突发异常的地方吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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