-
-
Notifications
You must be signed in to change notification settings - Fork 802
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add prompt error stacktrace if Debug = $true #560
Conversation
src/GitPrompt.ps1
Outdated
@@ -330,6 +330,10 @@ $PoshGitVcsPrompt = { | |||
if ($s) { | |||
Write-Prompt $s.BeforeText -BackgroundColor $s.BeforeBackgroundColor -ForegroundColor $s.BeforeForegroundColor | |||
Write-Prompt "Error: $_" -BackgroundColor $s.ErrorBackgroundColor -ForegroundColor $s.ErrorForegroundColor | |||
if ($s.Debug) { | |||
Write-Host | |||
Write-Verbose $_.ScriptStackTrace -Verbose |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about we change this line to:
Write-Verbose "PoshGitVcsPrompt error details:" -Verbose
Write-Verbose ($_ | Format-List * -Force | Out-String) -Verbose
Then we'd get more error info (including the script stacktrace) e.g.:
[PoshGitVcsPrompt error: kaboom]~\GitHub\dahlbyk\posh-git
04-14 12:15:30 280ms 2> $GitPromptSettings.Debug = $true
VERBOSE: 00010:Getting status
VERBOSE: 00060:Parsing status
VERBOSE: 00064:Status: ## rkeithhill/change-debugprompt...origin/rkeithhill/change-debugprompt
VERBOSE: 00066:Status: M src/GitPrompt.ps1
VERBOSE: 00067:Building status object
VERBOSE: 00087:Finished
VERBOSE: PoshGitVcsPrompt error details:
VERBOSE:
PSMessageDetails :
Exception : System.Management.Automation.RuntimeException: kaboom
TargetObject : kaboom
CategoryInfo : OperationStopped: (kaboom:String) [], RuntimeException
FullyQualifiedErrorId : kaboom
ErrorDetails :
InvocationInfo : System.Management.Automation.InvocationInfo
ScriptStackTrace : at Write-GitWorkingDirStatusSummary, C:\Users\Keith\GitHub\dahlbyk\posh-git\src\GitPrompt.ps1: line 776
at Write-GitStatus, C:\Users\Keith\GitHub\dahlbyk\posh-git\src\GitPrompt.ps1: line 202
at <ScriptBlock>, C:\Users\Keith\GitHub\dahlbyk\posh-git\src\GitPrompt.ps1: line 862
at <ScriptBlock>, C:\Users\Keith\GitHub\dahlbyk\posh-git\src\GitPrompt.ps1: line 855
at Global:Write-VcsStatus, C:\Users\Keith\GitHub\dahlbyk\posh-git\src\GitPrompt.ps1: line 855
at <ScriptBlock>, C:\Users\Keith\GitHub\dahlbyk\posh-git\src\posh-git.psm1: line 76
at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {}
But note that this will note capture any errors in the built-in prompt function as that function calls this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 consolidated into a single Write-Verbose
for no particular reason.
But note that this will not capture any errors in the built-in prompt function as that function calls this one.
True. I'm content with this for 0.x; the prompt function changes substantially in 1.0 anyway.
Though it occurs to me that this whole change isn't all that useful as folks can just look at $Error
to see what went wrong in either case. 🤷♂️
RE |
To help troubleshoot errors like #558.