有一个地方可以捕捉到钛合金中所有突然出现的例外情况?[英] one place to catch all sudden exceptions in titanium?

本文是小编为大家收集整理的关于有一个地方可以捕捉到钛合金中所有突然出现的例外情况?的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我是新的Android应用程序开发,并在使用我的应用程序期间经历令人不快的"网络越野"的情景. 我尝试在我的模拟器上再现它,但在应用程序仍在工作时进行"飞机模式".

我在app.js下尝试了:

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

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

如此善良的事情是我能够看到"抓住"但不是在我的应用程序之前看到一个红色屏幕细节并删除.见图片: app崩溃错误

如果有人可以帮助我识别如何捕捉所有这些"计划生命"的例外并根据某些业务逻辑指导,那将是非常有帮助的,以便用户不知道那些爆炸.

提前感谢

推荐答案

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

如果您将在您的应用中测试离线模式,则需要在没有LiveView的情况下运行它,因为它需要连接到工作.

参考:

捕获所有例外的事件未捕获的分发

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

本文地址:https://www.itbaoku.cn/post/1938239.html

问题描述

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.

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.

Thanks in advance

推荐答案

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.

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

For reference:

The event that catches all the exceptions is uncaughtException

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