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

error line numbers is skewed #6

Closed
zwetan opened this issue Jul 15, 2017 · 3 comments
Closed

error line numbers is skewed #6

zwetan opened this issue Jul 15, 2017 · 3 comments
Labels
Milestone

Comments

@zwetan
Copy link
Member

zwetan commented Jul 15, 2017

Because as3shebang wrap the main executing script into a custom wrapper
to allow nice colors and stuff

if an error occurs, the line number is skewed

@zwetan
Copy link
Member Author

zwetan commented Jul 15, 2017

example:

#!/usr/bin/env as3shebang -el -ec

import shell.*;
import C.macros.*;

trace( "local script" );

trace( "args = " + Program.argv );
trace( "file = " + __FILE__ );
trace( "line = " + __LINE__ );
trace( UNKNOWN );
//throw new Error( "hello world" );

trace( "EOF" );

trace( UNKNOWN ); is on line 11

but the error stack trace shows

ReferenceError: Error #1065: Variable UNKNOWN is not defined.
	at global$init()[:20]
	at shell::Runtime$/eval()
	at corsaair.tools.as3shebang::App/main()
	at global$init()

that's because the wrapper scripts add 9 lines at the top

@zwetan
Copy link
Member Author

zwetan commented Jul 15, 2017

ok problem fixed by saving the wrapper scripts line numbers
in the global var _global.as3sh_err_line_diff

and then scanning the error stack trace line number
subtracting this number
error_line_number

@zwetan
Copy link
Member Author

zwetan commented Jul 15, 2017

well ... the problem occurs again when the stack trace contains multiple line numbers

with this script

#!/usr/bin/env as3shebang -el -ec

import shell.*;
import C.macros.*;

function something()
{
    return UNKNOWN;
}

trace( "local script" );

trace( "args = " + Program.argv );
trace( "file = " + __FILE__ );
trace( "line = " + __LINE__ );
trace( something() );
//throw new Error( "hello world" );

trace( "EOF" );

return UNKNOWN; is on line 8
but the function call generating the error
trace( something() ); is on line 16

see
skewed_error_line_number

the first error number in the stack trace is correct

at Function/anonymous()[:8] for return UNKNOWN;

but the second line is incorrect
at global$init()[:25] for trace( something() );

should be at global$init()[:16]

@zwetan zwetan added the bug label Jul 15, 2017
@zwetan zwetan added this to the 1.1.0 milestone Jul 15, 2017
@zwetan zwetan closed this as completed Sep 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant