-
Notifications
You must be signed in to change notification settings - Fork 32
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
"Exception thrown from prompt block" even when the exception is handled within the block #68
Comments
Thought it might do with capturing of the error stream, but this caused the same behavior:
|
You'll have to PowerShell doesn't care that you're handling the error. I filed PowerShell/PowerShell#3768 about this years ago. Basically, we're always invoking your scriptblock within a script cmdlet with . { [CmdletBinding()]param()
try { throw "error" } catch {}
} -ErrorVariable logging It doesn't matter that you handled the exception -- it still shows up in the ErrorVariable, and there's nothing I can do about it except ignore all the errors (the way I do, if you set |
How about a way to ignore the error for a specific variable - base on output - or maybe even adding a custom object to the ErrorVariable? I understand it's hacky as hell, but then again, sometimes a hack makes sense. |
Thanks for that. One bizarre thread, a lively discussion, with an agreement from the PowerShell-committe throughout the course of a few month back in 2017. Almost implemented in 2019, accepted by the committee once more in 2020, only to be dropped because of an overworked engineer. Is this like this all the time? asking as you've been 'around the block' more than me. |
I wonder if there are updates on this topic, but as it is a pretty complex one to implement, I doubt... |
Run the following to test this issue:
The result is a WARNING:
$PromptErrors
contains:Tested on:
Expected behavior:
The text was updated successfully, but these errors were encountered: