Skip to content

Add error message to CrystalPath::NotFoundError#16365

Merged
straight-shoota merged 2 commits intocrystal-lang:masterfrom
willhbr:willhbr/push-tnunummuyqlv
Nov 17, 2025
Merged

Add error message to CrystalPath::NotFoundError#16365
straight-shoota merged 2 commits intocrystal-lang:masterfrom
willhbr:willhbr/push-tnunummuyqlv

Conversation

@willhbr
Copy link
Contributor

@willhbr willhbr commented Nov 14, 2025

If you use the run macro on a path that doesn't exist, you get a confusing empty error.

For example without this change, if you have the code:

{{ run "missing" }}

You get this error:

$ crystal build macro.cr
Showing last frame. Use --error-trace for full trace.

In macro.cr:1:4

 1 | {{ run "missing" }}
        ^--
Error: error executing macro 'run':

This is because in find_source_file it yields ex.message, which for a NotFoundError is empty.

This PR sets the message, so we get a more informative error:

$ crystal build macro.cr
Using compiled compiler at /home/will/Projects/crystal/.build/crystal
Showing last frame. Use --error-trace for full trace.

In macro.cr:1:4

 1 | {{ run "missing" }}
        ^--
Error: error executing macro 'run': Cannot find missing relative to /home/will/tmp

@straight-shoota straight-shoota merged commit 57da1f6 into crystal-lang:master Nov 17, 2025
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants