Document and critically review ShellError variants - Ep. 1#8229
Merged
sholderbach merged 8 commits intonushell:mainfrom Mar 1, 2023
Merged
Document and critically review ShellError variants - Ep. 1#8229sholderbach merged 8 commits intonushell:mainfrom
ShellError variants - Ep. 1#8229sholderbach merged 8 commits intonushell:mainfrom
Conversation
Instead of using tuple struct variants go for named struct variants to avoid confusion when creating `ShellError`s. The goal is to better document the errors and make them both more useful to the implementers as well as the users. A future goal of this effort is to enable serialization of errors to nushell records for finer-grained error handling.
The two variants are redundant. Naming the fields on `TypeMismatch` would be effectively the same as `TypeMismatchGenericMessage` We should make `TypeMismatch` more helpful anyways. (e.g. including both types and make sure spans are useful) When doing the joining it is worth checking for places where it is not a type error but something else.
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #8229 +/- ##
==========================================
- Coverage 68.53% 67.73% -0.81%
==========================================
Files 617 621 +4
Lines 99352 99287 -65
==========================================
- Hits 68093 67252 -841
- Misses 31259 32035 +776
|
sholderbach
commented
Feb 27, 2023
Comment on lines
82
to
+89
| Value::Error { .. } => value, | ||
| other => Value::Error { | ||
| error: ShellError::OnlySupportsThisInputType( | ||
| "integer".into(), | ||
| other.get_type().to_string(), | ||
| head, | ||
| // This line requires the Value::Error match above. | ||
| other.expect_span(), | ||
| ), | ||
| error: ShellError::OnlySupportsThisInputType { | ||
| exp_input_type: "integer".into(), | ||
| wrong_type: other.get_type().to_string(), | ||
| dst_span: head, | ||
| src_span: other.expect_span(), | ||
| }, |
Member
Author
There was a problem hiding this comment.
Thanks rust-analyzer for eating this comment in so many places... but the pervasive use of .expect_span() is a mistake in my view
Member
Author
There was a problem hiding this comment.
I think I have something figured out to factor out that gotcha after I am done with the error message stuff. So I would save my time reverting the removal of the comments.
ShellError variantsShellError variants - Ep. 1
Member
Author
|
To save me from rebasing all the time I prefer to split up this effort into several PRs. |
rgwood
approved these changes
Mar 1, 2023
Contributor
rgwood
left a comment
There was a problem hiding this comment.
Many, many thanks for this. It's so annoying to look at a ShellError variant and have no idea what the different fields mean. LGTM.
This was referenced Mar 5, 2023
sholderbach
added a commit
that referenced
this pull request
Mar 6, 2023
Continuation of #8229 # Description The `ShellError` enum at the moment is kind of messy. Many variants are basic tuple structs where you always have to reference the implementation with its macro invocation to know which field serves which purpose. Furthermore we have both variants that are kind of redundant or either overly broad to be useful for the user to match on or overly specific with few uses. So I set out to start fixing the lacking documentation and naming to make it feasible to critically review the individual usages and fix those. Furthermore we can decide to join or split up variants that don't seem to be fit for purpose. **Everyone:** Feel free to add review comments if you spot inconsistent use of `ShellError` variants. - Name fields of `SE::IncorrectValue` - Merge and name fields on `SE::TypeMismatch` - Name fields on `SE::UnsupportedOperator` - Name fields on `AssignmentRequires*` and fix doc - Name fields on `SE::UnknownOperator` - Name fields on `SE::MissingParameter` - Name fields on `SE::DelimiterError` - Name fields on `SE::IncompatibleParametersSingle` # User-Facing Changes (None now, end goal more explicit and consistent error messages) # Tests + Formatting (No additional tests needed so far)
sholderbach
added a commit
that referenced
this pull request
Mar 6, 2023
Continuation of #8229 and #8326 # Description The `ShellError` enum at the moment is kind of messy. Many variants are basic tuple structs where you always have to reference the implementation with its macro invocation to know which field serves which purpose. Furthermore we have both variants that are kind of redundant or either overly broad to be useful for the user to match on or overly specific with few uses. So I set out to start fixing the lacking documentation and naming to make it feasible to critically review the individual usages and fix those. Furthermore we can decide to join or split up variants that don't seem to be fit for purpose. # Call to action **Everyone:** Feel free to add review comments if you spot inconsistent use of `ShellError` variants. # User-Facing Changes (None now, end goal more explicit and consistent error messages) # Tests + Formatting (No additional tests needed so far) # Commits (so far) - Remove `ShellError::FeatureNotEnabled` - Name fields on `SE::ExternalNotSupported` - Name field on `SE::InvalidProbability` - Name fields on `SE::NushellFailed` variants - Remove unused `SE::NushellFailedSpannedHelp` - Name field on `SE::VariableNotFoundAtRuntime` - Name fields on `SE::EnvVarNotFoundAtRuntime` - Name fields on `SE::ModuleNotFoundAtRuntime` - Remove usused `ModuleOrOverlayNotFoundAtRuntime` - Name fields on `SE::OverlayNotFoundAtRuntime` - Name field on `SE::NotFound`
46 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The
ShellErrorenum at the moment is kind of messy.Many variants are basic tuple structs where you always have to reference the implementation with its macro invocation to know which field serves which purpose.
Furthermore we have both variants that are kind of redundant or either overly broad to be useful for the user to match on or overly specific with few uses.
So I set out to start fixing the lacking documentation and naming to make it feasible to critically review the individual usages and fix those.
Furthermore we can decide to join or split up variants that don't seem to be fit for purpose.
Feel free to add review comments if you spot inconsistent use of
ShellErrorvariants.ShellError::OperatorOverflowShellError::PipelineMismatchShellError::OnlySupportsThisInputTypeShellError::OnlySupportsThisInputTypeShellError::PipelineEmptyTypeMismatch*exp_input_typesShellError::InvalidRangeUser-Facing Changes
(None now, end goal more explicit and consistent error messages)
Tests + Formatting
(No additional tests needed so far)