October 2017
Intermediate to advanced
440 pages
11h 47m
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, a catastrophic failure that prevents a script continuing.
Read now
Unlock full access