one place to catch all sudden exceptions in titani

2019-07-23 03:16发布

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

1条回答
叼着烟拽天下
2楼-- · 2019-07-23 03:38

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.

查看更多
登录 后发表回答