Created
May 30, 2015 18:52
-
-
Save csharpforevermore/131df838e3aa9dd97e03 to your computer and use it in GitHub Desktop.
Powershell - get current exception line number and details
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$e = $_.Exception | |
$line = $_.InvocationInfo.ScriptLineNumber | |
$msg = $e.Message | |
Write-Host -ForegroundColor Red "caught exception: $e at $line" | |
Write-Host -ForegroundColor Red "An exception occurred." | |
Write-Host -ForegroundColor Red '$_ = ' $_ | |
Write-Host -ForegroundColor Red '$_.GetType().FullName = ' $_.GetType().FullName | |
Write-Host -ForegroundColor Red '$_.Exception = ' $_.Exception | |
Write-Host -ForegroundColor Red '$_.Exception.GetType().FullName = ' $_.Exception.GetType().FullName | |
Write-Host -ForegroundColor Red '$_.Exception.Message = ' $_.Exception.Message |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment