Skip to content

Commit

Permalink
Allow exceptions to be displayed for ScriptUpdateOnly param
Browse files Browse the repository at this point in the history
Correctly log the exceptions to avoid emailing in regarding an exception that is handled
  • Loading branch information
dpaulson45 committed Nov 27, 2024
1 parent 480d781 commit 706e225
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Diagnostics/HealthChecker/HealthChecker.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,23 @@ begin {

if ($ScriptUpdateOnly) {
Invoke-SetOutputInstanceLocation -FileName "HealthChecker-ScriptUpdateOnly"
$currentErrors = $Error.Count
switch (Test-ScriptVersion -AutoUpdate -VersionsUrl "https://aka.ms/HC-VersionsUrl" -Confirm:$false) {
($true) { Write-Green("Script was successfully updated.") }
($false) { Write-Yellow("No update of the script performed.") }
default { Write-Red("Unable to perform ScriptUpdateOnly operation.") }
}

if ($currentErrors -ne $Error.Count) {
Write-Host ""
Write-Warning "Failed to get latest version of script details. Failing with this inner exception:"
Write-Host ""
$Error[$Error.Count - $currentErrors - 1] | Out-String | Write-Host -ForegroundColor Red
Write-Host ""
Write-Host "Address the above exception in order to get the script to auto update."
}

Invoke-ErrorCatchActionLoopFromIndex $currentErrors
return
}

Expand Down

0 comments on commit 706e225

Please sign in to comment.