O'Reilly logo

Functional PHP by Gilles Crettenand

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

Exceptions

Error management is one of the toughest problems you face when writing software. It is often difficult to decide which piece of code should treat the error. Do it in the low-level function and you might not have access to the facilities to display an error message or enough context to decide the best course of action. Do it higher up and this might cause havoc in your data or put the application into an unrecoverable state.

The usual way to manage errors in OOP codebases is to use exceptions. You throw an exception in your library or utility code and you catch it whenever you are ready to manage it as you want.

Whether exception throwing and catching can be considered side effects or side causes is a matter for debate even among academics. ...

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