Terminating errors

A terminating error stops a pipeline processing; once an error is thrown, everything stops. A terminating error might appear as the result of using throw. In the following function, the second Write-Host statement will never execute:

PS> function ThrowError {
Write-Host 'First'
throw 'Error'
Write-Host 'Second'
}
PS>ThrowError
First
Error
At line:3 char:5
+ throw 'Error'
+ ~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (Error:String) [], RuntimeException
+ FullyQualifiedErrorId : Error

Terminating errors are typically used to convey that something unexpected and terminal has occurred, a catastrophic failure that prevents a script continuing.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.12.136.63