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

Add stack traceback to Lua error message. #140

Merged
merged 2 commits into from
Oct 29, 2020
Merged

Conversation

actboy168
Copy link
Contributor

@actboy168 actboy168 commented Oct 29, 2020

This change adds a stack traceback to Lua error messages to make it easier to find the error. At the same time, the call to setter and getter is changed from lua_pcall to lua_call, because now it is possible to know exactly where the error occurred in the setter and getter through the error message.

e.g.

<rml>
    <head>
        <script>
            function ButtonClick(document)
                document.title = {}
            end
        </script>
    </head>>
    <body>
        <button onclick="ButtonClick(document)">Click</button>
    </body>
</rml>

Before:

Document.__newindex for title: bad argument #2 to '?' (string expected, got table)

After:

bad argument #2 to '?' (string expected, got table)
stack traceback:
        [C]: in ?
        [C]: in metamethod 'newindex'
        [string "--test.rml..."]:4: in function 'ButtonClick'
        [string "ButtonClick(document)"]:1: in function <[string "ButtonClick(document)"]:1>

@mikke89
Copy link
Owner

mikke89 commented Oct 29, 2020

Very cool, thanks!

@mikke89 mikke89 merged commit 79f779c into mikke89:master Oct 29, 2020
@mikke89 mikke89 added the Lua Lua binding issues label Oct 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Lua Lua binding issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants