Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function WriteError
- {
- Write-Error "Error Occurred"
- "This still runs"
- }
- function PSCmdletWriteError
- {
- [CmdletBinding()]
- param()
- $PSCmdlet.WriteError([System.Management.Automation.ErrorRecord]::new([System.Exception]::new("This is my Exception"), "ErrorID", [System.Management.Automation.ErrorCategory]::NotSpecified, "ObjectThatThrewException"))
- "this still runs"
- }
- function TheThrow
- {
- throw "I am throwing an exception"
- "this does not run"
- }
- function PSCmdletThrowTerminatingError
- {
- [CmdletBinding()]
- param()
- $PSCmdlet.ThrowTerminatingError([System.Management.Automation.ErrorRecord]::new([System.Exception]::new("This is my *TERMINATING* exception"), "My Error ID", [System.Management.Automation.ErrorCategory]::LimitsExceeded, "ObjectThatThrewException"))
- "this doesn't run"
- }
- WriteError
- PSCmdletWriteError
- PSCmdletThrowTerminatingError
- TheThrow
- "I don't run because a throw was used"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement