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

Errors should consistently include filename, line number, and column number #1277

Closed
casey opened this issue Jul 24, 2022 · 5 comments
Closed

Comments

@casey
Copy link
Owner

casey commented Jul 24, 2022

I'd like to copy Rust's error messages, and have a line after the error message that starts with a --> and includes the filename, line number, and column number. So this error:

error: Recipe `foo` failed on line 2 with exit code 1

From this justfile:

foo:
  exit 1

Should look like this:

error: Recipe `foo` failed on line 2 with exit code 1
 --> justfile:2:3

This would allow tools to easily extract the error information and jump to the right place in the justfile.

Also, this would make the transition to any kind of multi-justfile world (e.g. includes, modules, etc) much easier, since we would already have the functionality for printing out the filename.

@BeatScherrer
Copy link

I try to work up to this since that might already be useful for me.

@casey
Copy link
Owner Author

casey commented Aug 3, 2022

@BeatScherrer Nice! I'd start with tests, add those, and then work from there. You can even open a draft PR with the failing tests, to confirm that they look good.

@Eloitor
Copy link

Eloitor commented Oct 15, 2023

What about allowing a message in case of failure? Something like python's assert

assert expression[, assertion_message]

I don't know what sintax to suggest, but maybe something like:

foo:
  exit 1
  > echo "X failed, do Y and try again"

@casey
Copy link
Owner Author

casey commented Nov 25, 2023

Fixed in #1737.

@casey casey closed this as completed Nov 25, 2023
@BeatScherrer
Copy link

Fixed in #1737.

That's really cool to see. I tried to work on this but got lost on how to implement it in the best way since I'm neither familiar with the just code base nor a proficient rust developer.

@casey casey unpinned this issue May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants