Repository navigation
Closed
Labels
A:error-unhelpfulThe error message you observe is not helpful to identify the problemcategory:meta-issueAn issue that tracks other issueshelp wantedstatus: Extra attention is needed
Milestone
Description
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 a ShellError which field goes where. This is exacerbated by the fact that for the miette 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
Reacted by Darren Schroeder
Metadata
Metadata
Assignees
Labels
A:error-unhelpfulThe error message you observe is not helpful to identify the problemcategory:meta-issueAn issue that tracks other issueshelp wantedstatus: Extra attention is needed
Activity
fdncred commentedon Oct 12, 2023
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!
kaiba42 commentedon Oct 19, 2023
tldr; ShellError variants should have record<> types for fields instead of strings.
I'm having some trouble dealing with these ShellError variants in
try { cmd } catch{|e| ...}blocks. Whencmdfails, the type of$eisrecord<msg: string, debug: string, raw: error>, which I can see is mapped fromShellError::ExternalCommand.The problem is that the fields within the record, the
debugstring is formatted asWhich 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
metadata ($e.debug)will actually yield arecord<span: record<start: int, end: int>>, which suggests that $e.debug is not merely a string. I think$e.debugshould be a record, not a string.sholderbach commentedon Oct 19, 2023
@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.
Convert ShellError::UnsupportedInput to named fields
Convert ShellError::UnsupportedInput to named fields (#10971)
Convert ShellError::DatetimeParseError to named fields
Convert ShellError::DatetimeParseError to named fields (#10991)
Convert ShellError::NetworkFailure to named fields
Convert ShellError::CommandNotFound to named fields
Convert ShellError::NetworkFailure to named fields
Convert ShellError::CommandNotFound to named fields
Convert ShellError::CommandNotFound to named fields (#11094)
37 remaining items
Convert remainder of ShellError variants to named fields (nushell#11276)
Convert ShellError::UnsupportedInput to named fields (nushell#10971)
Convert ShellError::DatetimeParseError to named fields (nushell#10991)
Convert ShellError::CommandNotFound to named fields (nushell#11094)
Convert ShellError::NetworkFailure to named fields (nushell#11093)
Remove ShellError::FlagNotFound (nushell#11119)
Convert ShellError::AliasNotFound to named fields (nushell#11118)
Convert FileNotFound to named fields (nushell#11120)
Convert FileNotFoundCustom to named fields (nushell#11123)
Convert PluginFailedToLoad to named fields (nushell#11124)
Convert PluginFailedToEncode to named fields (nushell#11125)
Convert PluginFailedToDecode to named fields (nushell#11126)
Convert more ShellError variants to named fields (nushell#11173)
Convert more ShellError variants to named fields (nushell#11222)
Convert remainder of ShellError variants to named fields (nushell#11276)