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

Runner: don't prefix Ruleset error notices #841

Merged
merged 1 commit into from
Feb 24, 2025

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Feb 23, 2025

Description

As things are, the Runner class catches any exception thrown by the Ruleset, enhances the message with an ERROR prefix, adds new lines and short help usage info and then re-throws this as a DeepExitException.

In an upcoming PR, a new MsgCollector class will be introduced, which will allow for both errors, as well as warnings, notices and deprecations.

This means that the ERROR prefix won't always be appropriate anymore.

This commit moves the ERROR prefix addition from the Runner class to the individual messages for the Exceptions being thrown in the Ruleset class.

Additionally, it changes the "trailing new lines" handling as the MsgCollector may also add new lines at the end of a message, as messages will not necessarily always be displayed via an exception (think: non-blocking deprecation notices). So to prevent a duplicate set of new lines, any new lines which are included in the exception are trimmed off before adding the new lines desired for the Exception display.

This is a preliminary step before introducing the MsgCollector to the Ruleset class.

Suggested changelog entry

N/A - This is an internal change only

Related issues/external references

Loosely related to #689

As things are, the `Runner` class catches any exception thrown by the Ruleset, enhances the message with an `ERROR` prefix, adds new lines and short help usage info and then re-throws this as a `DeepExitException`.

In an upcoming PR, a new `MsgCollector` class will be introduced, which will allow for both errors, as well as warnings, notices and deprecations.

This means that the `ERROR` prefix won't always be appropriate anymore.

This commit moves the `ERROR` prefix addition from the `Runner` class to the individual messages for the Exceptions being thrown in the `Ruleset` class.

Additionally, it changes the "trailing new lines" handling as the `MsgCollector` may also add new lines at the end of a message, as messages will not necessarily always be displayed via an exception (think: non-blocking deprecation notices).
So to prevent a duplicate set of new lines, any new lines which are included in the exception are trimmed off before adding the new lines desired for the Exception display.

_This is a preliminary step before introducing the `MsgCollector` to the `Ruleset` class._
@jrfnl jrfnl merged commit bf2b64d into master Feb 24, 2025
59 checks passed
@jrfnl jrfnl deleted the feature/runner-dont-prefix-ruleset-errors branch February 24, 2025 11:14
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.

2 participants