Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-10320] iOS: CommonJS: doesn't show where is it the offending line of code is in a module

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2013-01-14T14:09:49.000+0000
Affected Version/sRelease 2.0.2, Release 2.1.1, Release 3.0.0
Fix Version/sRelease 3.1.0, 2013 Sprint 01 Core, 2013 Sprint 01
ComponentsiOS
LabelsSupportTeam, core, module_require, notable, qe-testadded
ReporterEduardo Gomez
AssigneeMax Stepanov
Created2012-08-06T11:02:43.000+0000
Updated2013-07-17T06:14:55.000+0000

Description

Problem

It looks like the source file doesn't show when the offending line of code is in a commonjs module. The customer needs to identify where is the offending code line in order to narrow down the issue quicker.

Tested on

iOS 5.1 Simulator

Console

Actual output

[INFO] Launching application in Simulator
[INFO] Launched application in Simulator (23.09 seconds)
[INFO] Application started
[DEBUG] Reading stylesheet from: /Users/egomez/Library/Application Support/iPhone Simulator/5.1/Applications/A959F667-67EF-4247-A3DE-D0D4CB33EE06/Test.app/stylesheet.plist
[INFO] Test/1.0 (2.2.0.v20120801170113.b2782e9)
[DEBUG] Analytics is enabled = YES
[DEBUG] Loading: /Users/egomez/Library/Application Support/iPhone Simulator/5.1/Applications/A959F667-67EF-4247-A3DE-D0D4CB33EE06/1BestPractices.app/app.js, Resource: app_js
[DEBUG] Loading: /Users/egomez/Library/Application Support/iPhone Simulator/5.1/Applications/A959F667-67EF-4247-A3DE-D0D4CB33EE06/1BestPractices.app/module.js, Resource: module_js
[ERROR] Invalid type passed to function. expected: NSArray or nil, was: __NSCFString  in -[TiUIEmailDialogProxy open:] (TiUIEmailDialogProxy.m:64)
[ERROR] Script Error = Invalid type passed to function. expected: NSArray or nil, was: __NSCFString  in -[TiUIEmailDialogProxy open:] (TiUIEmailDialogProxy.m:64) (unknown file).
[DEBUG] Application booted in 11.829019 ms

Proposed-Expected output

[INFO] {
    line = 10;
    message = "'Script Error = Invalid type passed to function.";
    name = ScriptError;
    sourceId = 270794016;
    sourceURL = "file://localhost/Users/egomez/Library/Application%20Support/iPhone%20Simulator/5.1/Applications/CCA98E58-E7A1-453D-860E-4E310AA5F374/Test.app/module.js";
}

Test case

- app.js
var win1 = Titanium.UI.createWindow({ backgroundColor:'#fff' });

var accessor = require('module');
accessor.buildEmailView(/* to */ 'email@appc.com', /* subject */ 'Testing', /* defaultBody */ 'DefaultBody');

win1.open();
- module.js
exports.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);
        }
    });
 
};

TiStudio version

Titanium Studio, build: 2.2.0.201208021836 (c) Copyright 2012 by Appcelerator, Inc. All rights reserved. Build: jenkins-titanium-rcp-development-921 (origin/development) Date: 02 August 2012, 18:39:42

Attachments

FileDateSize
AppError_2.2.jpg2012-08-06T11:02:43.000+000093364

Comments

  1. Ivan Skugor 2012-08-11

    Getting exception info is painful. IMHO, exception data should be standardized (file, line number, error type and message should be available on all platforms).
  2. Max Stepanov 2012-09-14

    This ticket is partially fixed by TIMOB-10501. More exception details is to come.
  3. Max Stepanov 2012-12-20

    PR https://github.com/appcelerator/titanium_mobile/pull/3625
  4. Blain Hamon 2013-01-09

    CR rejected. Methods would be difficult to maintain and there are more elegant solutions.
  5. Blain Hamon 2013-01-11

    CR and FR passed, pull merged. For some reason, it won't let me update the status. Please change to 'Review passed' or the like.
  6. Blain Hamon 2013-01-14

    Pull merged
  7. Priya Agarwal 2013-07-17

    Updated label. Closing as fixed. Verified with: Studio: 3.1.2.201307121617 Titanium SDK: 3.1.2.v20130710144553 acs:1.0.3 alloy:1.1.3 npm:1.2.14 titanium:3.1.1 titanium-code-processor:1.0.1 OS: OSX 10.8 Device:iPhone Simulator(v6.0) iphone4(v5.1) Xcode: 4.5.1 CommonJS showing proper error which is offending line of code as per expectation.

JSON Source