- Notifications
You must be signed in to change notification settings - Fork7.7k
Explicitly specify ErrorRecord to use in DetailedView error format script#25627
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1324,7 +1324,7 @@ function Get-ConciseViewPositionMessage { | ||
} | ||
if ($ErrorView -eq 'DetailedView') { | ||
$message = Get-Error$err| Out-String | ||
MatejKafka marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
return "${errorColor}${message}${resetcolor}" | ||
} | ||
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -211,5 +211,14 @@ Describe 'Tests for $ErrorView' -Tag CI { | ||||
$e | Should -BeExactly (Get-Error | Out-String).Trim([Environment]::NewLine.ToCharArray()) | ||||
} | ||||
It 'Renders the passed error instead of the last one' { | ||||
# PR #25627 | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Why remove the comment? It is useful to get more context as to why such a weird behavior is even tested. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. We never add such comments. | ||||
$ErrorView = 'DetailedView' | ||||
$first = try {throw "first"} catch {$_} | ||||
try {throw "second"} catch {} | ||||
# DetailedView internally calls 'Get-Error' to render the output, ensure that it picks up the correct error | ||||
$first | Out-String | Should -BeLike '*throw "first"*' | ||||
} | ||||
} | ||||
} |