Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-18103] Generic Error Handling

GitHub Issuen/a
TypeNew Feature
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2015-06-04T01:09:34.000+0000
Affected Version/sn/a
Fix Version/sRelease 4.1.0
ComponentsAndroid, iOS
Labelserror, handling
ReporterDawson Toth
AssigneeIngo Muschenetz
Created2014-11-27T03:03:33.000+0000
Updated2017-03-16T22:44:53.000+0000

Description

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!');

Comments

  1. Dawson Toth 2014-11-27

    PR for Android and iOS implementation of example solution: https://github.com/appcelerator/titanium_mobile/pull/6407
  2. Chee Kiat Ng 2015-06-04

    CR and FT passed. PR Merged.
  3. Lee Morris 2017-03-16

    Closing ticket as fixed.

JSON Source