O'Reilly logo

PowerShell Deep Dives by Edited by Jeffery Hicks, Richard Siddaway, Oisín Grehan, and Aleksandar Nikoli

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 11. A template for handling and reporting errors

Will Steele

Writing programs that work when everything goes as expected is a good start. Making your programs behave properly when encountering unexpected conditions is where it really gets challenging.

Marijn HaverbekeEloquent JavaScript: A Modern Introduction to Programming

Efficient, predictable error handling has been at the core of PowerShell’s design since its earliest days and has allowed scripters to design robust automation solutions with minimal effort. In small scripts a balanced combination of common parameters, the use of Write-Error, or perhaps Write-Warning, and some well-placed if/then statements generally prove to be enough for most scripter’s daily automation problems. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required