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

Include module name in the error message #301

Open
dnbsd opened this issue Dec 30, 2024 · 1 comment
Open

Include module name in the error message #301

dnbsd opened this issue Dec 30, 2024 · 1 comment

Comments

@dnbsd
Copy link

dnbsd commented Dec 30, 2024

Risor's compiler produces very terse error messages, which makes finding the issue in scripts spanning multiple modules difficult.

For instance, the following is an error message from a script which imports another module that is referencing an undefined variable:

$ go run ../cmd/risor main.risor 
compile error: undefined variable "jfaijfeao" (line 1)
exit status 1

The error message omits the name of the module where the error has originated. It also omits the column number. Please, compare with an error produced by the parser:

$ go run ../cmd/risor main.risor
parse error: unterminated block statement

location: line 3, column 4
for{
   ^
exit status 1

Again, module name is not reported, though the provided information is very detailed and helps narrow down the issue to a character.

@robbyt
Copy link

robbyt commented Jan 20, 2025

@dnbsd it might be helpful to look at the code for how the parser shows the "Friendly" error message:

result, err := risor.Eval(ctx, string(code))
if err != nil {
if friendlyErr, ok := err.(errz.FriendlyError); ok {
http.Error(w, friendlyErr.FriendlyErrorMessage(), http.StatusBadRequest)
} else {
http.Error(w, err.Error(), http.StatusBadRequest)
}
return

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

2 participants