Skip to content
Discussion options

You must be logged in to vote

Hi everybody,

we usually use the following trap definition to get useful info about errors such as stack traces:

trap {
    Write-Host "$($PSStyle.Foreground.Red)$($_.Exception)$($PSStyle.Reset)"
    Write-Host "$($PSStyle.Foreground.Magenta)$($_.ScriptStackTrace)$($PSStyle.Reset)"
    throw $_.Exception
}

For the .build.ps1 we can't yet get it to work properly, which I guess is caused by the way Invoke-Build works (which I don't know yet) in combination with how traps are designed: PowerShell/PowerShell#25742

However, I wonder if there is any workaround or alternative?

Imagine the following example:

# .build.ps1

# setup default error handling
Set-StrictMode -Version 3.0
$ErrorActionPre…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@boernsen-development
Comment options

Answer selected by boernsen-development
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants