Skip to content

Commit

Permalink
Fixing the detection of errors when using ErrorVariable
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmarsy committed May 18, 2015
1 parent b6dd6ea commit 4754915
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions GitPrompt.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -159,16 +159,16 @@ if(!(Test-Path Variable:Global:VcsPromptStatuses)) {

function Global:Write-VcsStatus {
$Global:VcsPromptStatuses | foreach {
$vcsPromptError = $null
$vcsPromptErrors = $null
try {
Invoke-Command -ScriptBlock $_ -ErrorVariable vcsPromptError 2>$null
Invoke-Command -ScriptBlock $_ -ErrorVariable vcsPromptErrors 2>$null
}
catch {
$vcsPromptError = $_
$vcsPromptErrors = $_
}
if ($null -ne $vcsPromptErrors) {
# Log the error but dont affect the users prompt, splat the thrown object onto Write-Error so the relevant properties are automatically assigned
Write-Error -ErrorAction SilentlyContinue @vcsPromptError
if ($vcsPromptErrors.Length -gt 0) {
# Log the errors but dont affect the users prompt, splat error objects into Write-Error
$vcsPromptErrors | % { Write-Error -ErrorAction SilentlyContinue @_ }
$s = $Global:GitPromptSettings
if ($s) {
Write-Prompt $s.BeforeText -BackgroundColor $s.BeforeBackgroundColor -ForegroundColor $s.BeforeForegroundColor
Expand Down

0 comments on commit 4754915

Please sign in to comment.