Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to determine on which line the error and which file. #429

Open
rotorgames opened this issue Apr 20, 2015 · 10 comments
Open

How to determine on which line the error and which file. #429

rotorgames opened this issue Apr 20, 2015 · 10 comments

Comments

@rotorgames
Copy link

In the application, Hello World (Alloy).
Try to call a nonexistent function test:

// buttom onclick
function doClick(e) {
    test(); // Function test does not exist.
}

$.index.open();

The console shows:

[ERROR] [android, 4.4.2, 192.168.43.103] {
  "message": "Uncaught ReferenceError: test is not defined",
  "lineOffset": 9,
  "line": 12,
  "title": "Runtime Error",
  "lineSource": "        test();",
  "sourceName": "undefined"
}

Try to call a nonexistent function in the controller

// buttom onclick
function doClick(e) {

}

$.index.open();


test(); // Function test does not exist.

The console shows:

[ERROR] [android, 4.4.2, 192.168.43.103] 
Type: ReferenceError
Message: test is not defined
File: eval at custom_require : api/PlatformRequire.js
Line: 24
At:   new Controller

Why line and even files that was a mistake, do not match?
Perhaps, as you use the source map with tishadow?
Without this, it becomes very difficult to debug.

@dbankier
Copy link
Owner

source maps would be good. I think you'll get the wrong lines with straight alloy as well (since it is precompiled).

@rotorgames
Copy link
Author

@dbankier The problem with tishadow much deeper source map and here plays a small role.
Tishadow uses eval that would fulfill the source code. In this case, you can only get the error string in the main file, any errors in the require hidden.

I'm working on source titanium, that would be able to use native tishadow require.

Developing code for IOS, I was finished, now working with Android.

Changes for IOS: rotorgames/titanium_mobile@dce1cb1

P.S. Code for Android is almost finished, but I have little time. I hope it will soon appear, and I'll pull request in titanium.

@dbankier
Copy link
Owner

@rotorgames, that is TiShadow used to be back in 2012.

This commit roles it back and moves to the eval way (273ed75)

These are the native commits back then for both iOS and Android that made it work.
dbankier/titanium_mobile@d332a84
dbankier/titanium_mobile@0b9b8ab

I moved away from that since it meant having custom tishadow builds for every sdk release. That used to happen more frequently and it was a hassle to maintain.

It might be worth revisiting as native modules...

@rotorgames
Copy link
Author

@dbankier I have a very different approach.
Titanium does not need to know about the existence of tishadow. Titanium has only to provide methods for other plugins.

How it will work:

Tishadow adds tiapp.xml line parameter.

<Property name = "customDirectory" type = "string"> applicationDataDirectory:/{name}/{platform} </ property>

After that, any request require will first look in the folderapplicationDataDirectory:/{name}/{platform}

For example:

require ("lib/q.js") // /data/data/com.rotorgames.myappname/app_data/MyAppName/android/lib/q.js

Then, if the file in this folder will not be made a request to the default folder.

Thus, there is no mention of tishadow, and this method may be to Use any plugin or application developer.

Support Directory:

applicationDataDirectory
tempDirectory
applicationCacheDirectory
externalStorageDirectory

Support Values

deploytype
id
publisher
url
name
version
description
copyright
guid
familyTarget // Android: phone || tablet; IOS: Iphone, Ipad
platform // ios || android
family // iphone || android
undName // My App Name == My_App_Name

@dbankier
Copy link
Owner

Right. nice!
From what I understand, that would only work then with express/appified, unless the property can be modified at runtime. Also, I think you'd still need some standard require access...
Good luck with the PR! Give a shout if you need help.

@rotorgames
Copy link
Author

@dbankier I'll do a separate Pull Request for tishadow, which I will consider all the changes titanium.

Concerning, standard require access any ideas? How best to do it?

require ("app.js", bool);

Where bool boolean value, true if taken from a standard repository, if false or undefiend is taken from the custom warehouse.

Or make a separate function for this?

In general, is it necessary? I have done so if the require not find the file in the custom folder, it searches the standart folder, if there is not, then an error. This is convenient but there is no control.

Any ideas?

P.S. I think if I change the way of calling require appcelerator is unlikely to be thrilled by this.

@dbankier
Copy link
Owner

not sure if AppC will accept that, or this:
perhaps better is require("app.js", root_path)
either way it breaks the spec so I doubt you'll get it through.

@rotorgames
Copy link
Author

@dbankier Done, Pull Request for Android and IOS.
tidev/titanium-sdk#6901

Soon prepare Pull Request for Tishadow

@dbankier
Copy link
Owner

dbankier commented Jun 9, 2015

nice - I'll be watching it.

@xedef
Copy link

xedef commented Aug 24, 2016

Any updates on this? Would be awesome to have it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants