February 2019
Intermediate to advanced
626 pages
15h 51m
English
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> ThrowErrorFirstErrorAt 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, such as a catastrophic failure that prevents a script continuing.
Read now
Unlock full access