Exceptional PHP: Nesting Exceptions In PHP

In the last two entries we have talked about the concept of layer abstraction: that is, that exceptions should not be allowed to pass out of one layer and into another. So, when an exception is raised in the database layer it should be caught in the controller. But how do we go about making sure that exceptions raised in the database layer are properly recorded and processed, ensuring that we have error logging and don’t simply silence our exceptions?

There are a number of ways to encapsulate one exception within another, or “nest” our exceptions. Let’s discuss the ways.


Thursday, November 12th, 2009 @ 1:00 am | Comment (1) | Categories: Best Practices, PHP 5, Object-Oriented Development, Technology
Tags: , ,

Exceptional PHP: Extending The Base Exception Class

On Monday, we talked about the basics of exceptions and how they are used in PHP (as well as in other object-oriented programming languages). As promised, today we are going to talk about extending the base exception class in PHP.

One of the things that you can (and should) do with PHP exceptions is extend them to suit your own purposes. While the base Exception class in PHP is neither abstract nor impossible to use on its own, extending exceptions give you a great amount of flexibility and power, particularly in three areas: customization, identification, and abstraction.


Wednesday, November 11th, 2009 @ 1:00 am | Comment (5) | Categories: Technology, Best Practices, PHP 5, Object-Oriented Development
Tags: , , ,

Copyright © 2024 by Brandon Savage. All rights reserved.