Crystal: ECR errors should include the calling site line number information

Created on 7 Mar 2020  路  4Comments  路  Source: crystal-lang/crystal

Think we need more helpful errors, ie, including the calling site info, when using ECR. I've a Kemal application with hundreds of routes and I see this not very helpful message when I missed defining "title" var for one of the routes.

Error target foo failed to compile:
Showing last frame. Use --error-trace for full trace.

In views/form.ecr:9:61

 9 | <h1 class="title is-3 has-text-dark"><%=title%></h1>
                                             ^----
Error: undefined local variable or method 'title' for top-level

crystal -v
Crystal 0.33.0 (2020-02-14)

LLVM: 9.0.1
Default target: x86_64-apple-macosx

All 4 comments

Quick update, I can tell the offending line by using --error-trace however there is now too much noise to wade through just to get to the line number. Would be nice if the original error somehow just included the line number where the ECR macro is being called.

GET!

Closing. --error-trace is the way to go until we do something like #8410

Was this page helpful?
0 / 5 - 0 ratings