The Problem
When an unhandled error occurs in production (or in builds distributed to testers), the error is either completely lost, or is displayed in a rather unfriendly red dialog. This includes both native and JavaScript errors.
Desired Solution
Let the developer receive errors in their JavaScript. They can then do whatever they want with the error, such as logging it, or displaying a dialog to the user. These errors should be sent regardless of if the app is running in production or not.
Example
Ti.App.addEventListener('uncaughtException', function(evt) {
alert({
// Both iOS and Android:
message: evt.message,
line: evt.line,
// iOS Only:
sourceId: evt.sourceId,
type: evt.type,
sourceURL: evt.sourceURL,
backtrace: String(evt.backtrace).substr(0, 100) + '...',
// Android Only:
title: evt.title,
sourceName: evt.sourceName,
lineSource: evt.lineSource,
lineOffset: evt.lineOffset
});
});
throw new Error('Hello, error handler!');
PR for Android and iOS implementation of example solution: https://github.com/appcelerator/titanium_mobile/pull/6407
CR and FT passed. PR Merged.
Closing ticket as fixed.