9.1. Handling Errors

Errors in PowerShell can be of two kinds: terminating and nonterminating. The first kind of is similar to the exception concept found in many programming languages. Those are errors that are triggered because the command interpreter has encountered an exceptional situation and cannot continue. Once we raise such an error, all further execution stops. Typical terminating errors are raised by script syntax errors, trying to call nonexistent commands, or something of a similar severity. User-raised errors resulting from the throw statement, which we will look into later in this chapter, are also terminating errors.

Nonterminating errors are less severe. Those are usually errors indicating that the current command cannot be ...

Get Pro Windows PowerShell now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.