-
Notifications
You must be signed in to change notification settings - Fork 130
Error view #215
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
Error view #215
Changes from 5 commits
5fd9c69
3dd0560
a7d6a75
6faa7dc
c454366
fb60588
f4edfcd
a6329e7
0641bb2
8dabf42
5cf273d
07af6d2
da03165
8cdd56a
6de0c3e
697327c
d6f6af4
889cad4
9439d35
51ec0f2
1f272cd
a58d4e8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,182 @@ | ||
--- | ||
RFC: Update $ErrorView with Single String Error Messages | ||
Author: Jason Helmick | ||
Status: Draft | ||
Version: 0.0.0 | ||
Area: PowerShell | ||
Comments Due: 08/31/2019 | ||
Plan to implement: Yes | ||
--- | ||
|
||
# Update $ErrorView with Single String Error Messages | ||
|
||
When an error occurs in PowerShell, the customers on-screen error message experience currently | ||
provides a level of detail that obscures the inner exception message from being read by | ||
new or occasional PowerShell users. | ||
To improve both comprehension and the troubleshooting experience, a single string of text | ||
containing the error will be displayed. A cmdlet will provide the full error details when desired. | ||
|
||
## Motivation | ||
|
||
The on-screen experience, when receiving an error message, | ||
is controlled through the views NormalView (the default) and CategoryView. These are user selectable though the preference variable $ErrorView. | ||
theJasonHelmick marked this conversation as resolved.
Show resolved
Hide resolved
|
||
The addition of a “ConciseView” as default that contains only specific error | ||
theJasonHelmick marked this conversation as resolved.
Show resolved
Hide resolved
|
||
information producing a single line on screen and in logs will improve customer success. | ||
theJasonHelmick marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Comprehensive error information is available to the customer through | ||
accessing the error object. For new and occasional customers, | ||
a cmdlet “Resolve-ErrorRecord” will simplify the process of getting detailed error information, improving customers success. | ||
|
||
## Specification | ||
|
||
The proposal is to add a new single-line default error message view called ConciseView | ||
and add a new cmdlet (Resolve-ErrorRecord) to provide detailed error information. | ||
|
||
__Key Design Considerations__ | ||
|
||
1. To reduce confusion and improve debugging success, | ||
error messages by default should produce a single line of text, including the word “ERROR:” to make consistent with Verbose and Warning messages. This is added to $errorView as view named "ConciseView". | ||
|
||
theJasonHelmick marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- $ErrorView should contain these views | ||
|
||
+ NormalView | ||
theJasonHelmick marked this conversation as resolved.
Show resolved
Hide resolved
|
||
+ CategoryView | ||
+ ConciseView | ||
|
||
theJasonHelmick marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- Error Message syntax for ConciseView | ||
|
||
```powershell | ||
ERROR: <Exception Message>: <Positional Info> | ||
ERROR: Cannot find path ‘C:\blah’ because it does not exist: At line:1 char:1 | ||
``` | ||
|
||
2. A new cmdlet “Resolve-ErrorRecord” will produce detailed error information similar to Format-List * -Force. | ||
theJasonHelmick marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
theJasonHelmick marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- Resolve-ErrorRecord will provide the following: | ||
|
||
+ Display Last Error ($Error[0]) – default behavior | ||
+ Accept Pipeline input – support $error[1] | | ||
+ Option for the first X errors in the session | ||
+ Option for the Last X errors in the session | ||
|
||
- Resolve-ErrorRecord syntax | ||
|
||
```powershell | ||
Resolve-ErrorRecord [-InputObject <psobject>] [-Newest <Int32>] [-First <Int32>] [-All] [<CommonParameters>] | ||
``` | ||
|
||
First parameter set | ||
|
||
- Newest | ||
|
||
+ Datatype: int32 | ||
+ specifies one or more of last errors to display | ||
+ Not required | ||
|
||
- First | ||
theJasonHelmick marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
+ Datatype: Int32 | ||
+ Specifies one or more of the first errors that occurred | ||
+ Not required | ||
|
||
- All | ||
|
||
+ Datatype: Switch | ||
+ Specifies display all errors in session | ||
+ Not required | ||
|
||
Examples | ||
|
||
```powershell | ||
# Displays details of the last error displayed | ||
Resolve-ErrorRecord | ||
|
||
# Displays error details from pipeline error object | ||
$error[1] | Resolve-ErrorRecord | ||
|
||
# Display detailed error information for the last 5 errors | ||
Resolve-ErrorRecord -Last 5 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like you originally had There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The examples still show |
||
|
||
# Display detailed error information for the first 3 errors | ||
Resolve-ErrorRecord -First 3 | ||
|
||
# Display detailed information for all errors that occured in the session | ||
Resolve-ErrorRecord -All | ||
``` | ||
__Example 1__ | ||
|
||
```powershell | ||
PS C:\test> Get-item c:\blah | ||
Get-item : Cannot find path 'C:\blah' because it does not exist. At line:1 char:1 | ||
|
||
PS C:\test> Resolve-ErrorRecord | ||
theJasonHelmick marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
PSMessageDetails : | ||
Exception : System.Management.Automation.ItemNotFoundException: Cannot find path 'C:\blah' because it does | ||
not exist. | ||
at System.Management.Automation.LocationGlobber.ExpandMshGlobPath(String path, Boolean | ||
allowNonexistingPaths, PSDriveInfo drive, ContainerCmdletProvider | ||
|
||
``` | ||
|
||
__Example 2__ | ||
|
||
```powershell | ||
PS C:\test> slkjdfh | ||
ERROR: The term 'slkjdfh' is not recognized as the name of a cmdlet, function, script file, or operable program. At line:1 char:1 | ||
PS C:\test> $error[0] | Resolve-ErrorRecord | ||
|
||
PSMessageDetails : | ||
Exception : System.Management.Automation.CommandNotFoundException: The term 'slkjdfh' is not recognized as | ||
``` | ||
|
||
## Alternate Proposals and Considerations | ||
|
||
__Alternative single-line display__ | ||
|
||
```powershell | ||
<CommandName>:<Exception Message> | ||
get-item: Cannot find path ‘C:\blah’ because it does not exist: | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would drop the position and make this the concise/simple view. In my experience, when users see line numbers, that, coupled with red text, encourages them to go straight to the script developer. Or better, make it conditional. Only show the position if it comes from a file. Otherwise, it is not needed in the concise/simple view. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, don't include position (in the default output) unless it's related to an actual file There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 3rded and like the conditional |
||
<CommandName>:<Exception Message>: <Position> | ||
get-item: Cannot find path ‘C:\blah’ because it does not exist: At line:1 char:1 | ||
|
||
<CommandName>:<Alias>:<Exception Message>: <Position> | ||
get-item: gi: Cannot find path ‘C:\blah’ because it does not exist: At line:1 char:1 | ||
|
||
ERROR:<Exception Message> | ||
ERROR: Cannot find path ‘C:\blah’ because it does not exist | ||
|
||
ERROR:<Exception Message>: <Position> | ||
ERROR: Cannot find path ‘C:\blah’ because it does not exist: At line:1 char:1 | ||
|
||
ERROR:<CommandName>:<Alias>:<Exception Message>: <Position> | ||
ERROR: get-item: gi: Cannot find path ‘C:\blah’ because it does not exist: At line:1 char:1 | ||
``` | ||
|
||
__Alternative color for all errors__ | ||
|
||
1. We could change the default error message color from the current RED foreground and BLACK background to... | ||
2. Differentiating errors based on termination condition: terminating versus non-terminating is currently not intuitive. We are examining differentiating these conditions on the console. Example, adding a new property $host.PrivateData.NonTerminatingErrorForegroundColor ='Red'. | ||
For occasional customers, all error messages remain as color Red. For advanced customers, they can change non-terminating errors to another color to separate the error termination type in the console. | ||
|
||
__Alternative For Error, Warning, Verbose__ | ||
|
||
1. We could be more terse in our messages and increase consistency with verbose and warning messages by using a single letter to identify the message. | ||
|
||
Legend: V = Verbose, W = Warning, E = Error(non-terminating future), F = Fatal | ||
|
||
```powershell | ||
V: You are running your code - what could possibly go wrong. | ||
|
||
W: You are about to try something that probably will not work. | ||
|
||
E: Your something broke, but Im still running. At line:1 char:1 | ||
|
||
E: Your something broke, but Im still running. At line:1 char:1 | ||
|
||
E: Your something broke, but Im still running. At line:1 char:1 | ||
|
||
F: Now you really broke me. At line:1 char:1 | ||
|
||
``` | ||
theJasonHelmick marked this conversation as resolved.
Show resolved
Hide resolved
|
Uh oh!
There was an error while loading. Please reload this page.