Skip to content

Support non-string errors with SourceMapTraceback#741

Merged
Perryvw merged 3 commits intoTypeScriptToLua:masterfrom
TheLartians:master
Oct 26, 2019
Merged

Support non-string errors with SourceMapTraceback#741
Perryvw merged 3 commits intoTypeScriptToLua:masterfrom
TheLartians:master

Conversation

@TheLartians
Copy link
Copy Markdown
Contributor

@TheLartians TheLartians commented Oct 25, 2019

Currently the custom debug.traceback function set for SourceMapTracebacks assumes errors to be invoked with string error messages. However, this is not the case in an xpcall context, where error may be invoked with any object by the user.

Example

Input

function f() { throw Error(); }
const [ok, error] = xpcall(() => f(), debug.traceback);

Current Output:

Errors with

./.test/test.lua:114: bad argument #1 to 'gsub' (string expected, got table)
stack traceback:
        ./.test/test.lua:113: in function 'debug.traceback'
        [C]: in function 'string.gsub'
        ./.test/test.lua:114: in function 'debug.traceback'
        [C]: in function 'error'
        ./.test/test.lua:138: in function 'f'
        (...tail calls...)
        [C]: in function 'xpcall'
        ./.test/test.ts:15: in main chunk
        [C]: in ?

After PR

Runs correctly and error is set to the thrown Error object.

@TheLartians TheLartians changed the title Support custom errors with SourceMapTraceback Support non-string errors with SourceMapTraceback Oct 25, 2019
@Perryvw Perryvw merged commit 0f5c5aa into TypeScriptToLua:master Oct 26, 2019
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

Successfully merging this pull request may close these issues.

2 participants