Skip to content

Commit

Permalink
Adding try/catch logic to Write-VcsStatus
Browse files Browse the repository at this point in the history
Adding try/catch logic to Write-VcsStatus so that if one of the scriptblocks that has been added to the VcsPromptStatuses array fails the other scriptblocks are still invoked and the effect on the user's prompt is minimized

Use of the ErrorVariable parameter during invocation is to also capture any errors that were written to the error stream
  • Loading branch information
paulmarsy committed May 22, 2015
1 parent 69324d4 commit 14c1b55
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion GitPrompt.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,6 @@ function Global:Write-VcsStatus {
$PoshGitVcsPrompt = {
$Global:GitStatus = Get-GitStatus
Write-GitStatus $GitStatus
}
}
$Global:VcsPromptStatuses += $PoshGitVcsPrompt
$ExecutionContext.SessionState.Module.OnRemove = { $Global:VcsPromptStatuses = $Global:VcsPromptStatuses | ? { $_ -ne $PoshGitVcsPrompt} }

0 comments on commit 14c1b55

Please sign in to comment.