Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23621] Windows: Improve error message when passing an invalid number of arguments to a function

GitHub Issuen/a
TypeImprovement
PriorityNone
StatusClosed
ResolutionFixed
Resolution Date2016-08-30T05:22:14.000+0000
Affected Version/sRelease 5.4.0
Fix Version/sRelease 6.1.0
ComponentsWindows
Labelsqe-5.4.0
ReporterEwan Harris
AssigneeKota Iguchi
Created2016-07-11T17:09:29.000+0000
Updated2016-12-08T00:26:45.000+0000

Description

Description

When calling a function that has a minimum required number of args, in the example provided I use the appendRow method with only 1 argument, the error below is printed out
[ERROR] :  Application Error: {
[ERROR] :    "line": 2,
[ERROR] :    "column": 10,
[ERROR] :    "message": "Error while require(/app) invalid vector<T> subscript",
[ERROR] :    "native_stack": [
[ERROR] :      "JSExportClass<class Titanium::GlobalObject>::CallNamedFunction"
[ERROR] :    ]
[ERROR] :  }
However when building for Android the following error is thrown, which explains the reason for the error
[ERROR] :  TiExceptionHandler: (main) [70,70] ----- Titanium Javascript Runtime Error -----
[ERROR] :  TiExceptionHandler: (main) [0,70] - In app.js:7,7
[ERROR] :  TiExceptionHandler: (main) [0,70] - Message: Uncaught Error: insertRowAfter: Invalid number of arguments. Expected 2 but got 1
[ERROR] :  TiExceptionHandler: (main) [1,71] - Source: table.insertRowAfter(Ti.UI.createTableViewRow({ title: 'notEnoughArgs' }));
[ERROR] :  V8Exception: Exception occurred at app.js:7: Uncaught Error: insertRowAfter: Invalid number of arguments. Expected 2 but got 1
Demo code
var win = Ti.UI.createWindow();
Ti.UI.createTableViewRow({ title: 'Bananas' });
var table = Ti.UI.createTableView({});
table.insertRowAfter(Ti.UI.createTableViewRow({ title: 'notEnoughArgs' }));
win.add(table);
win.open();

Steps to reproduce

1. Using the code above build for Windows Platform using appc run -p windows -T wp-emulator

Actual result

The first error will be shown, which gives the user no help in diagnosing the issue

Expected result

An error similar to the Android error should be shown, informing the user why the error was thrown

Comments

  1. Kota Iguchi 2016-08-22

    https://github.com/appcelerator/titanium_mobile_windows/pull/831
  2. Samir Mohammed 2016-12-08

    Verified improvement, message is more clear to indicate what the error is ; error message shown below.
       [ERROR] :  ----- Titanium Javascript Runtime Error -----
       [ERROR] :  In app.js: 4,21
       [ERROR] :  Message: Uncaught Error: insertRowAfter: Invalid number of arguments. Expected 2 but got 1
       
    *Environment*
       Operating System
         Name                        = Microsoft Windows 10 Pro
         Version                     = 10.0.14393
         Architecture                = 64bit
         # CPUs                      = 4
         Memory                      = 17034395648
        
       Node.js
         Node.js Version             = 4.4.4
         npm Version                 = 2.11.3
        
       Titanium CLI
         CLI Version                 = 5.0.10
        
       Titanium SDK
         SDK Version                 = 6.1.0.v20161207121046
       
  3. Samir Mohammed 2016-12-08

    Further environment information.
       Windows Emulator: Mobile Emulator 10.0.14393.0 1080p 6 inch 2GB 
       

JSON Source