If you’re a PHP developer who wants to learn the basics of implementing customized exceptions in PHP 5, then look no further, because you’ve come to the right place. This is the third part of a four-part series entitled “Subclassing exceptions in PHP 5.” It teaches you how to extend the native exception mechanism bundled with PHP 5 by using inheritance, and complements the corresponding theory with copious, illustrative hands-on examples.
Having already introduced you to the main subject of this article series, it's time to summarize the topics that were discussed in the last article, in case you haven't read it yet. In that particular tutorial I explained how to implement a fully-functional customized exception system with PHP 5, which came in handy for handling a number of specific exceptions thrown by a basic MySQL abstraction class.
However, the most relevant part of developing such a exception handling system was the small number of steps it actually took. All I had to do was derive a basic subclass from the pertinent built-in "Exception" class, and provide it with the programming logic required to handle those MySQL-related exceptions. Period.
Of course, although PHP 5 permits us to work with exception subclasses in a relative easy way, this doesn't mean that all of your existing or future applications must incorporate this feature. However, there's a number of situations, particularly when working with large-scale projects, where it's often necessary to utilize customized exceptions.
And speaking of customized exceptions, in the last article I demonstrated how to build a MySQL abstraction class that implemented these in a useful fashion, so in this third tutorial I'm going to show you how to handle all of the errors that might occur when processing MySQL data sets via a specific exception mechanism.
Are you ready to continue learning about the creation of exception subclasses with PHP 5? Let's get going!