5ERROR HANDLING

Images

You’ve seen how to use variables and control flow structures to write flexible code that can respond to the imperfections of the real world—servers that aren’t up when they should be, files that are in the wrong place, and the like. Some of these things you know to expect and can handle accordingly. But you’ll never be able to anticipate every error. There’s always something that will break your code. The best you can do is write code that breaks responsibly.

That’s the basic premise behind error handling, the techniques that developers use to ensure that their code expects and takes care of—or handles—errors. In this chapter, ...

Get PowerShell for Sysadmins 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.