Skip to content

Instantly share code, notes, and snippets.

@adbertram
Created November 14, 2018 12:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save adbertram/58d8524596da4095dd03b9b069d86179 to your computer and use it in GitHub Desktop.
Save adbertram/58d8524596da4095dd03b9b069d86179 to your computer and use it in GitHub Desktop.
function Debug-Error {
[OutputType([void])]
[CmdletBinding()]
param
()
$action = {
if ($_ -and ($stacktrace -notmatch '^\s*at System\.Management\.Automation\.ExceptionHandlingOps\.CheckActionPreference') -and ($stacktrace -notmatch '^\s*at System\.Management\.Automation\.MshCommandRuntime\.ThrowTerminatingError\(ErrorRecord errorRecord\)\s*$')) {
break
}
}
$null = Set-PSBreakpoint -Variable stackTrace -Mode Write -Action $action
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment