Skip to content

Deprecate print_error function and replace it with new print_error_and_exit function#5092

Open
Flamefire wants to merge 8 commits intoeasybuilders:developfrom
Flamefire:print-error
Open

Deprecate print_error function and replace it with new print_error_and_exit function#5092
Flamefire wants to merge 8 commits intoeasybuilders:developfrom
Flamefire:print-error

Conversation

@Flamefire
Copy link
Contributor

@Flamefire Flamefire commented Jan 14, 2026

There is a print_error function in output and this one additionally
exits which is not reflected in the name.
Also the handling of the parameters is confusing, e.g. using log to
determine whether to throw an EasyBuildError.
Deprecate it and replace by print_error_and_exit, translating the
arguments from one to the other.

CI error is due to use of log.error which is disallowed since #1218

Only easybuild.base seems to be exempted with a comment (which seems to be outdated)

# don't check Python modules in easybuild.base namespace (ingested vsc-base)

That is also the source of the weird construct:

elif log is not None:
        raise EasyBuildError(message)

TBH I don't really like having EasyBuildError log an error in all cases as we sometimes catch it and do something else instead. But maybe this just means we should not raise it so often.

I removed the log parameter (again)

There is a `print_error` function in `output` and this one additionally
exits which is not reflected in the name.
Also the handling of the parameters is confusing, e.g. using `log` to
determine whether to throw an `EasyBuildError`.
Deprecate it and replace by `print_error_and_exit`, translating the
arguments from one to the other.
Only used in one place and all error logging should happen in the
constructor of `EasyBuildError` since easybuilders#1218
@boegel boegel changed the title Replace print_error by print_error_and_exit Replace use print_error by print_error_and_exit Jan 14, 2026
@boegel boegel changed the title Replace use print_error by print_error_and_exit Deprecate print_error function and replace it with new print_error_and_exit function Jan 14, 2026
@boegel boegel added the change label Jan 14, 2026
@boegel boegel added this to the next release (5.2.1?) milestone Jan 14, 2026
if testing:
raise EasyBuildError(msg)
eb_go.parser.print_shorthelp()
print_error_and_exit(msg)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

End out produced output will look like this:

All long option names can be passed as environment variables. Variable name is
EASYBUILD_<LONGNAME> eg. --some-opt is same as setting EASYBUILD_SOME_OPT in
the environment.
ERROR: Please provide one or multiple easyconfig files, or use software build options to make EasyBuild search for easyconfigs

So the error message "drowns" a bit because it blends in with the short help output.

Let's add one (or two) newlines in between?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this was the case before.

We have output.print_error which adds a newline before and after the message. Would be great if we could use that. A bit confusing that print_error are in output but print_msg and print_warning in build_log. I'd move all to one of them but we can't as we either get a cycle or break backwards compat with build_log.print_error (which used to exit)

I'm now calling output.print_error from here to have a uniform appearance of printed errors.

Flamefire and others added 5 commits January 14, 2026 16:54
Co-authored-by: Kenneth Hoste <kenneth.hoste@ugent.be>
Use `easybuild.tools.print_error` for a uniform appearance
This is called in error handlers and using `rich` can cause errors.
Co-authored-by: Kenneth Hoste <kenneth.hoste@ugent.be>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants