Skip to content

Instantly share code, notes, and snippets.

@nohwnd
Created January 6, 2019 09:38
Show Gist options
  • Save nohwnd/02dd7af0fac84b1d379810727458a852 to your computer and use it in GitHub Desktop.
Save nohwnd/02dd7af0fac84b1d379810727458a852 to your computer and use it in GitHub Desktop.
Navigatable stack trace
function a () {
b
}
function b () {
c
}
function c () {
throw "error"
}
try {
a
} catch {
"Standard output:"
$_
"Full stack trace:"
$_.ScriptStackTrace | Out-String |
# change the output
# from: at file.ps1 line 13
# to: at file.ps1:13
foreach { $_ -replace '\s*line\s+(\d+)','$1'}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment