Skip to content

Builtin error function gives misleading message #3704

Description

@tpoliaw

As far as I can make out, the error builtin function provides a way for recipes to bail out with a message if some pre-conditions are not met. When used, the message given to the user suggests the error function failed rather than the surrounding recipe.

Example (very contrived) justfile

demo arg:
    {{ if arg == "foo" { error("arg cannot be 'foo'") } else { arg } }}

other:
    mkdir /cant/make/root/directories

Running this as just demo foo, gives the output

error: call to function `error` failed: arg cannot be 'foo'
 ——▶ justfile:5:28
  │
5 │     {{ if arg == "foo" { error("arg cannot be 'foo'") } else { arg } }}
  │                          ^^^^^

Both the "call to function `error` failed" and the code snippet make the error look like it was at a lower level than it was.

Would it be possible to make the error more similar to other recipe errors

error: recipe `demo` failed on line 5: arg cannot be 'foo'

to match the other recipe from the above example

mkdir /cant/make/root/directories
mkdir: cannot create directory ‘/cant/make/root/directories’: No such file or directory
error: recipe `other` failed on line 9 with exit code 1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions