Skip to content

Commit

Permalink
Fix container failure output (#2167)
Browse files Browse the repository at this point in the history
  • Loading branch information
nohwnd committed Apr 29, 2022
1 parent ec2131a commit c79a6fa
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/functions/Output.ps1
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

0 comments on commit c79a6fa

Please sign in to comment.