[TIMOB-11652] iOS: Add script errors/stack trace to TiExceptionHandler data
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | High |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2013-01-16T10:19:40.000+0000 |
| Affected Version/s | Release 3.0.0 |
| Fix Version/s | Release 3.0.2, Release 3.1.0, 2012 Sprint 23 API, 2012 Sprint 23 |
| Components | Core |
| Labels | exception, qe-port, triage |
| Reporter | Max Stepanov |
| Assignee | Blain Hamon |
| Created | 2012-11-02T17:16:43.000+0000 |
| Updated | 2014-07-06T20:11:52.000+0000 |
Description
JavaScript:
// Without try catch:
var err = new Error("My Awesome Caught Error!");
API.logHandledException(err);
try {
var err = new Error("My Awesome Caught Error!");
throw err
} catch (err){
API.logHandledException(err);
}
Objective-C:
-(void)logHandledException:(id)args
{
TiLogMessage([NSString stringWithFormat:@"class type?: %@", [[args objectAtIndex:0] class]]); // This returns as NSDictionary, is this expected?
// TiScriptError *exception = [TiScriptError initWithDictionary:[args objectAtIndex:0]]; // This selector doesn't exist?
TiScriptError *exception = (TiScriptError *)args; // Returns an array, not a single object. In other methods, they returned the objects rather than an array of parameters.
[API logHandledException:[self convertScriptErrorToNative:exception]];
}
Reopening so that we can bring TiJSCore in. Also, documentation.
A test case:
Output will be something like:var win1 = Titanium.UI.createWindow({ backgroundColor:'#fff' }); var accessor = {}; accessor.buildEmailView = function(to, subject, defaultBody) { var emailDialog = Ti.UI.createEmailDialog(); emailDialog.setSubject(subject); emailDialog.setToRecipients(to); emailDialog.setMessageBody(defaultBody); emailDialog.setHtml(true); emailDialog.setBarColor('#312f2c'); emailDialog.open(); emailDialog.addEventListener('complete',function(e) { if (e.result == emailDialog.SENT) { alert("message was sent"); } else { alert("message was not sent. result = "+e.result); } }); }; accessor.buildEmailView(/* to */ 'email@appc.com', /* subject */ 'Testing', /* defaultBody */ 'DefaultBody'); win1.open();The expected result should contain valid 'backtrace' property:value pair.[ERROR] Script Error { backtrace = "#0 () at file://localhost/Users/max/Library/Application%20Support/iPhone%20Simulator/4.3.2/Applications/86EAB896-F4E9-4672-9426-D20F7FAED5F1/Titanium.app/app.js:29"; line = 13; message = "Invalid type passed to function"; nativeLocation = "-[TiUIEmailDialogProxy open:] (TiUIEmailDialogProxy.m:63)"; nativeReason = "expected: NSArray or nil, was: NSCFString"; sourceId = 208722560; sourceURL = "file://localhost/Users/max/Library/Application%20Support/iPhone%20Simulator/4.3.2/Applications/86EAB896-F4E9-4672-9426-D20F7FAED5F1/Titanium.app/app.js"; }Closing. Tested and verified fix with: Device: iPhone5 iOS 6.0 Titanium Studio, build: 3.0.1.201212181159 Titanium SDK, build: 3.0.2.v20130125153221 Titanium SDK, build:3.1.0.v20130125152545 Similar output.