Improve error when regex rejects pattern. Resolution of #8037#8050
Improve error when regex rejects pattern. Resolution of #8037#8050fdncred merged 3 commits intonushell:mainfrom
Conversation
|
nice research and fix. thanks! |
Codecov ReportBase: 55.23% // Head: 54.86% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #8050 +/- ##
==========================================
- Coverage 55.23% 54.86% -0.38%
==========================================
Files 606 606
Lines 99065 99060 -5
==========================================
- Hits 54720 54348 -372
- Misses 44345 44712 +367
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
|
Thanks! The error message makes it much more obvious what's wrong. |
|
I'm checking out why the line is not covered by the test and it seems like the test is not being run at all. Maybe the str tests are disabled for some reason. EDIT: Actually, I want the tests locally and the test is being run. It's just somehow it doesn't get included in the coverage report. @sholderbach Do you have an idea why the test is not covered? Because it seems to exercise the code path. There is no other line that could return the IncorrectValue error which is what the test checks. |
| /// A command received an argument with correct type but incorrect value. | ||
| /// | ||
| /// ## Resolution | ||
| /// | ||
| /// Correct the argument value before passing it in or change the command. | ||
| #[error("Incorrect value.")] | ||
| #[diagnostic(code(nu::shell::incorrect_value), url(docsrs))] | ||
| IncorrectValue(String, #[label = "{0}"] Span), |
There was a problem hiding this comment.
Might be worth investigating if we already have similar variants that are poorly documented.
Description
Improve error when
str replace <pattern>detects a problem with .User-Facing Changes
New "Incorrect value" error:
We could fruitfully replace some of the current uses of
ShellError::UnsupportedInputwith this error. 'Incorrect value' is different from 'wrong type'Tests + Formatting
Don't forget to add tests that cover your changes.
Make sure you've run and fixed any issues with these commands:
cargo fmt --all -- --checkto check standard code formatting (cargo fmt --allapplies these changes)cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collectto check that you're using the standard code stylecargo test --workspaceto check that all tests passAfter Submitting
If your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.