22
Error Handling
Errors communicate unexpected conditions and exceptional circumstances. Errors often contain useful information that can be used to diagnose a problem.
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 ...
Get Mastering PowerShell Scripting - Fifth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.