Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix container failure output #2167

Merged
merged 1 commit into from
Apr 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/functions/Output.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ function Get-WriteScreenPlugin ($Verbosity) {
}
else {
& $SafeCommands["Write-Host"] -ForegroundColor $ReportTheme.Fail $errorHeader
Write-ErrorToScreen $formatErrorParams
Write-ErrorToScreen @formatErrorParams
}
}

Expand Down Expand Up @@ -840,10 +840,14 @@ function Format-CIErrorMessage {
[Parameter(Mandatory)]
[string] $Header,

[Parameter(Mandatory)]
# [Parameter(Mandatory)]
# Do not make this mandatory, just providing a string array is not enough for the
# mandatory check to pass, it also throws when any item in the array is empty or null.
[string[]] $Message
)

$Message = if ($null -eq $Message) { @() } else { $Message }

$lines = [System.Collections.Generic.List[string]]@()

if ($CIFormat -eq 'AzureDevops') {
Expand Down Expand Up @@ -889,10 +893,14 @@ function Write-CIErrorToScreen {
[Parameter(Mandatory)]
[string] $Header,

[Parameter(Mandatory)]
# [Parameter(Mandatory)]
# Do not make this mandatory, just providing a string array is not enough,
# for the mandatory check to pass, it also throws when any item in the array is empty or null.
[string[]] $Message
)

$PSBoundParameters.Message = if ($null -eq $Message) { @() } else { $Message }

$errorMessage = Format-CIErrorMessage @PSBoundParameters

foreach ($line in $errorMessage) {
Expand Down Expand Up @@ -944,7 +952,8 @@ function Format-ErrorMessage {
if ($null -ne $Err.DisplayErrorMessage) {
[void]$errorMessageSb.Append($Err.DisplayErrorMessage)

if ($null -ne $Err.DisplayStackTrace -and $StackTraceVerbosity -ne 'None') {
# Don't try to append the stack trace when we don't have it or when we don't want it
if ($null -ne $Err.DisplayStackTrace -and [string]::empty -ne $Err.DisplayStackTrace.Trim() -and $StackTraceVerbosity -ne 'None') {
$stackTraceLines = $Err.DisplayStackTrace -split [Environment]::NewLine

if ($StackTraceVerbosity -eq 'FirstLine') {
Expand Down