Skip to content

Commit 815e19a

Browse files
committed
Make it actually work
1 parent a642b86 commit 815e19a

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

ErrorView.ps1xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@
1818
</ExpressionBinding>
1919
<ExpressionBinding>
2020
<ScriptBlock>
21-
"Hello World"
22-
if ($formatter = Get-Command "ConvertTo-Error$($ErrorView)" -ListImported) {
23-
&amp;$formatter $_
21+
if ($formatter = Get-Command "ConvertTo-Error*$($ErrorView)*" -ListImported) {
22+
&amp;@($formatter)[0] $_
2423
} else {
2524
ConvertTo-ErrorNormalView $_
2625
}

ErrorView.psd1

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
CompanyName = 'PoshCode'
66

77
RootModule = 'ErrorView.psm1'
8-
FormatsToProcess = 'ErrorView.ps1xml'
98
ModuleVersion = '0.0.1'
109
CompatiblePSEditions = @("Core", "Desktop")
1110

ErrorView.psm1

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
param(
2+
[ArgumentCompleter({ (Get-Command ConvertTo-Error* -ListImported).Name -replace "ConvertTo-Error(?:View)?(.*)(?:View)",'$1' })]
3+
$ErrorView
4+
)
5+
6+
# We need to overwrite the ErrorView
7+
# So -PrependPath, instead of FormatsToProcess
8+
Update-FormatData -PrependPath $PSScriptRoot\ErrorView.ps1xml
9+
110
function Write-NativeCommandError {
211
[CmdletBinding()]
312
param(
@@ -37,7 +46,6 @@ function Write-NativeCommandError {
3746
$myinv.InvocationName + " : "
3847
}
3948
}
40-
4149
function ConvertTo-ErrorCategoryView {
4250
[CmdletBinding()]
4351
param(
@@ -48,7 +56,6 @@ function ConvertTo-ErrorCategoryView {
4856
$CurrentError.CategoryInfo.GetMessage()
4957
}
5058

51-
5259
function ConvertTo-ErrorSimpleView {
5360
[CmdletBinding()]
5461
param(
@@ -95,7 +102,6 @@ function ConvertTo-ErrorSimpleView {
95102
}
96103
}
97104
}
98-
99105
function ConvertTo-ErrorNormalView {
100106
[CmdletBinding()]
101107
param(

0 commit comments

Comments
 (0)