Public/Get-ChromiumError.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function Get-ChromiumError {
<#
.SYNOPSIS
Retrieve a more detailed reason why the last vault command failed.
.NOTES
This will be deprecated when https://github.com/PowerShell/SecretManagement/issues/93 is addressed
#>

    param(
        $Newest = 1
    )
    
    [Exception[]]$vaultErrors = $GLOBAL:Error.where{$PSItem.CategoryInfo.TargetType -eq 'ExtensionVaultModule'}.Exception | 
        Select-Object -First $Newest
        
    if ($vaultErrors) {
        foreach ($errorItem in $vaultErrors) {
            [String]$errorMessage = $errorItem.message + ': ' + $errorItem.InnerException.Message
            $Host.UI.WriteErrorLine($errorMessage)
        }
    }
}