Error Handling
Errors communicate unexpected conditions and exceptional circumstances. Errors often contain useful information that you can use to diagnose a condition.
PowerShell has two different types of errors, terminating and non-terminating, and several different ways to raise and handle them.
Error handling in PowerShell is a complex topic, which is not helped by incorrect assertions in help documentation surrounding terminating errors. These challenges are explored in this chapter.
Self-contained blocks of code are described as scripts in this chapter. That is, functions, script blocks, and scripts can be considered interchangeable in the context of error handling.
This chapter covers the following topics:
- Error types
- Error actions
- Raising errors
- Catching errors