Skip to content

Instantly share code, notes, and snippets.

@johndonnelly
Forked from adbertram/Debug-Error.ps1
Created November 16, 2018 22:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johndonnelly/e61a65769dbd640c830d9e8b92471d35 to your computer and use it in GitHub Desktop.
Save johndonnelly/e61a65769dbd640c830d9e8b92471d35 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