-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Make ShellError
more readable by consistently using named fields
#10700
Comments
It would be nice to pin this but I'm not sure which other pinned issue to remove. Would love to have more consistency across our ShellError messages! |
tldr; ShellError variants should have record<> types for fields instead of strings. I'm having some trouble dealing with these ShellError variants in The problem is that the fields within the record, the
Which isn't able to be parsed into a structured data type to my knowledge. However, it clearly is more than just a string to nushell, because running |
@kaiba42 there is certainly some extra work necessary to make sure as a Nushell user you have access to the relevant fields. But, yes completing this internal polishing here should make it easier to cleanly serialize the internal error to a Nushell record. |
This is easy to do with rust-analyzer, but I didn't want to just pump these all out without feedback. Part of nushell#10700
# Description This is easy to do with rust-analyzer, but I didn't want to just pump these all out without feedback. Part of #10700 # User-Facing Changes None # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting N/A --------- Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com>
# Description Part of #10700 # User-Facing Changes None # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting N/A
# Description `ShellError::FlagNotFound` had a note that said it may be removable so this PR removes it instead of updating it to named fields per #10700 I can't see this error being used since it was introduced with #4364. I can't find why or where it was used before that date, though. There was a large merge with that PR but I can't penetrate the secrets of git to find out where its earlier history went. # User-Facing Changes None # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting N/A
# Description Part of #10700 # User-Facing Changes None # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting N/A
# Description Part of #10700 # User-Facing Changes None # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting N/A
@drbrain |
# Description This is easy to do with rust-analyzer, but I didn't want to just pump these all out without feedback. Part of nushell#10700 # User-Facing Changes None # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting N/A --------- Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com>
# Description Part of nushell#10700 # User-Facing Changes None # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting N/A
# Description Part of nushell#10700
# Description Part of nushell#10700
# Description `ShellError::FlagNotFound` had a note that said it may be removable so this PR removes it instead of updating it to named fields per nushell#10700 I can't see this error being used since it was introduced with nushell#4364. I can't find why or where it was used before that date, though. There was a large merge with that PR but I can't penetrate the secrets of git to find out where its earlier history went. # User-Facing Changes None # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting N/A
# Description Part of nushell#10700 # User-Facing Changes None # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting N/A
# Description Part of nushell#10700 # User-Facing Changes None # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting N/A
# Description Part of nushell#10700 # User-Facing Changes None # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting N/A
# Description Part of nushell#10700 # User-Facing Changes None # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting N/A
# Description Part of nushell#10700 # User-Facing Changes None # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting N/A
# Description Part of nushell#10700 # User-Facing Changes None # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting N/A
# Description Convert these ShellError variants to named fields: * CreateNotPossible * MoveNotPossibleSingle * DirectoryNotFoundCustom * DirectoryNotFound * NotADirectory * OutOfMemoryError * PermissionDeniedError * IOErrorSpanned * IOError * IOInterrupted Also place the `span` field of `DirectoryNotFound` last to match other errors. Part of nushell#10700 (almost half done!) # User-Facing Changes None # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting N/A
# Description Convert errors to named fields: * NeedsPositiveValue * MissingConfigValue * UnsupportedConfigValue * DowncastNotPossible * NonUtf8Custom * NonUtf8 * DidYouMeanCustom * DidYouMean * ReadingFile * RemoveNotPossible * ChangedModifiedTimeNotPossible * ChangedAccessTimeNotPossible Part of nushell#10700
# Description Removed variants that are no longer in use: * `NoFile*` * `UnexpectedAbbrComponent` Converted: * `OutsideSpannedLabeledError` * `EvalBlockWithInput` * `Break` * `Continue` * `Return` * `NotAConstant` * `NotAConstCommand` * `NotAConstHelp` * `InvalidGlobPattern` * `ErrorExpandingGlob` Fixes nushell#10700 # User-Facing Changes None # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting N/A
# Description This is easy to do with rust-analyzer, but I didn't want to just pump these all out without feedback. Part of nushell#10700 # User-Facing Changes None # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting N/A --------- Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com>
# Description Part of nushell#10700 # User-Facing Changes None # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting N/A
# Description Part of nushell#10700
# Description Part of nushell#10700
# Description `ShellError::FlagNotFound` had a note that said it may be removable so this PR removes it instead of updating it to named fields per nushell#10700 I can't see this error being used since it was introduced with nushell#4364. I can't find why or where it was used before that date, though. There was a large merge with that PR but I can't penetrate the secrets of git to find out where its earlier history went. # User-Facing Changes None # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting N/A
# Description Part of nushell#10700 # User-Facing Changes None # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting N/A
# Description Part of nushell#10700 # User-Facing Changes None # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting N/A
# Description Part of nushell#10700 # User-Facing Changes None # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting N/A
# Description Part of nushell#10700 # User-Facing Changes None # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting N/A
# Description Part of nushell#10700 # User-Facing Changes None # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting N/A
# Description Part of nushell#10700 # User-Facing Changes None # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting N/A
# Description Convert these ShellError variants to named fields: * CreateNotPossible * MoveNotPossibleSingle * DirectoryNotFoundCustom * DirectoryNotFound * NotADirectory * OutOfMemoryError * PermissionDeniedError * IOErrorSpanned * IOError * IOInterrupted Also place the `span` field of `DirectoryNotFound` last to match other errors. Part of nushell#10700 (almost half done!) # User-Facing Changes None # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting N/A
# Description Convert errors to named fields: * NeedsPositiveValue * MissingConfigValue * UnsupportedConfigValue * DowncastNotPossible * NonUtf8Custom * NonUtf8 * DidYouMeanCustom * DidYouMean * ReadingFile * RemoveNotPossible * ChangedModifiedTimeNotPossible * ChangedAccessTimeNotPossible Part of nushell#10700
# Description Removed variants that are no longer in use: * `NoFile*` * `UnexpectedAbbrComponent` Converted: * `OutsideSpannedLabeledError` * `EvalBlockWithInput` * `Break` * `Continue` * `Return` * `NotAConstant` * `NotAConstCommand` * `NotAConstHelp` * `InvalidGlobPattern` * `ErrorExpandingGlob` Fixes nushell#10700 # User-Facing Changes None # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting N/A
Our
ShellError
still has a number of variants that are tuple structs (i.e. unnamed list of types to provide). Especially if there are multiple fields of the same type it is unclear at the creation side of aShellError
which field goes where. This is exacerbated by the fact that for themiette
diagnostics we have sometimes format strings that make strong assumptions what should be provided for a particular field.Thus we should convert each of them to named struct variants (i.e.
Identifier { field: type, ... }
). While doing so it is worth checking if we use the fields of the error correctly. Sometimes we might need to change incompatible uses of a variant to a different variant.Variants that need named fields
UnsupportedInput
DatetimeParseError
NetworkFailure
CommandNotFound
AliasNotFound
-FlagNotFound
FileNotFound
FileNotFoundCustom
PluginFailedToLoad
PluginFailedToEncode
PluginFailedToDecode
IOInterrupted
IOError
IOErrorSpanned
PermissionDeniedError
OutOfMemoryError
NotADirectory
DirectoryNotFound
DirectoryNotFoundCustom
MoveNotPossibleSingle
CreateNotPossible
ChangeAccessTimeNotPossible
ChangeModifiedTimeNotPossible
RemoveNotPossible
NoFileToBeRemoved
NoFileToBeMoved
NoFileToBeCopied
ReadingFile
DidYouMean
DidYouMeanCustom
NonUtf8
NonUtf8Custom
DowncastNotPossible
UnsupportedConfigValue
MissingConfigValue
NeedsPositiveValue
GenericError
OutsideSpannedLabeledError
RemovedCommand
UnexpectedAbbrComponent
EvalBlockWithInput
Break
Continue
Return
NotAConstant
NotAConstCommand
NotAConstHelp
Example PRs
ShellError
variants - Ep. 1 #8229ShellError
variants - Ep. 2 #8326ShellError
variants - Ep. 3 #8340The text was updated successfully, but these errors were encountered: