You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: ReadMe.md
+55-2Lines changed: 55 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,60 @@ This is a _very_ simple module. It exports one important command: `Format-Error`
7
7
*`ConvertTo-CategoryErrorView`
8
8
*`ConvertTo-NormalErrorView`
9
9
*`ConvertTo-SimpleErrorView`
10
+
*`ConvertTo-FullErrorView`
10
11
11
-
But more importantly, _when it's imported_, it allows you to override PowerShell's error formatting by setting the global `$ErrorView` variable to something like "SingleLine" and writing a function `ConvertTo-SingleLineErrorView` (i.e. `ConvertTo-<name>ErrorView`), and of course, it provides a "Simple" error view on top of PowerShell's existing "Normal" and "Category" views.
12
+
### Install it from PSGallery
12
13
13
-

14
+
```powershell
15
+
Install-Module ErrorView
16
+
```
17
+
18
+
_When it's imported_, it sets PowerShell's global `$ErrorView` variable to "Simple" and provides an implementation as `ConvertTo-SimpleErrorView`. **More importantly**, it allows you to write your own ErrorView! For example you could write a function or script `ConvertTo-SingleLineErrorView` and then set the preference variable `$ErrorView = "SingleLine"`, or even set it as you import the ErrorView module:
19
+
20
+
```powershell
21
+
Import-Module ErrorView -Args SingleLine
22
+
```
23
+
24
+
NOTE: by default, there is no "SingleLine" view in the ErrorView module. The default after importing the module is the "Simple" error view, which is currently a 2-line view.
25
+
26
+

27
+
28
+
### Format-Error
29
+
30
+
The `Format-Error` command lets you change the view temporarily to look at more details of errors, and even has a -Recurse switch to let error views show details of inner exceptions. If you have set your view to Simple (which is the default after importing the module), you can see the Normal view for the previous error by just running `Format-Error`. To see more than one error, you can look at the previous 5 errors like: `$error[0..4] | Format-Error`
31
+
32
+
### Custom Error Views
33
+
34
+
As stated above, the ErrorView module allows you to write your own formats. Here's an example, and a few pointers:
0 commit comments