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

Provide Span information in Errors #496

Open
elkowar opened this issue Dec 3, 2024 · 0 comments
Open

Provide Span information in Errors #496

elkowar opened this issue Dec 3, 2024 · 0 comments

Comments

@elkowar
Copy link

elkowar commented Dec 3, 2024

It would be very helpful if there was some way to get span information for Lua errors – especially stuff like syntax errors. This would allow users to provide much better error diagnostics when something goes wrong. Especially in case of applications that expose Lua to the user, such as when Lua is used as a configuration language, or for embedded expressions in templating logic, this could massively improve the user experience.

I am very unfamiliar with the actual API that the different Lua implementations expose internally, so this might just be impossible to achieve... But I would hope that it isn't.
We are getting a line number in the rendered error message, and from what I can see at least during runtime there seems to be some ways to get that sort of information via inspect_stack.

Having a simple error_span: Option<Range<usize>> representing offsets into the loaded lua code where the error occurred would be perfect, but even just getting the line number, or the span of the surrounding scope, or whatever is viable to implement, would already be a massive help.

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

1 participant