PHP
  Home arrow PHP arrow Building a Modular Exception Class in PHP 5
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Building a Modular Exception Class in PHP 5
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 2
    2008-11-05


    Table of Contents:
  • Building a Modular Exception Class in PHP 5
  • Review: Handling MySQL-related exceptions with two subclasses
  • Centralizing the processing of MySQL-related exceptions
  • Handling MySQL-related exceptions through one single subclass

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Building a Modular Exception Class in PHP 5
    ( Page 1 of 4 )

    Welcome to the final part of the four-part series “Subclassing exceptions in PHP 5.” By means of a hands-on approach, this series walks you through using inheritance to build finely-tuned exception subclasses. These subclasses can be used to handle, via multiple “try-catch” blocks, several failures that might occur during the execution of a given web application.

    Introduction

    Working with generic exceptions in PHP 5 is a fairly easy process that can be tackled with minor hassles. This is true even if you're starting to get your hands dirty developing web applications that utilize them to handle a certain number of critical conditions.

    Things can be a bit more complicated, however, when it's necessary to work with customized exceptions. This specific situation requires that you derive some exception subclasses from the built-in one provided by PHP 5, and that you use multiple "try-catch" blocks within the same application.

    Of course, if you're an experienced PHP 5 developer with a solid background in working with exceptions, then you've probably mastered them already. However, if you're just getting started with employing them in your own applications, and want to know how to build a customized exception mechanism in a few simple steps, then this article series might be what you need.

    Now, getting straight to the point, you'll possibly recall that in the last article I demonstrated how to build a customized exception system in PHP 5, which had the capacity to catch not only generic exceptions, but a couple of additional ones, triggered when working specifically with MySQL.

    In short, the system in question was smart enough to handle two well-differentiated kinds of exceptions: first, the ones triggered when connecting to the MySQL server, selecting a particular database, and running SQL queries; and second, exceptions that could be thrown when manipulating result sets.

    Nonetheless, handling the aforementioned types of exceptions demanded the use of two different subclasses, which in a case like this is really unnecessary. Therefore, in this concluding article of the series, I'm going to implement a similar MySQL exception mechanism, but this time by using only one subclass.

    So, are you ready to tackle the final chapter of this educational journey? Let's begin now!



     
     
    >>> More PHP Articles          >>> More By Alejandro Gervasio
     

       

    PHP ARTICLES

    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL
    - Method Chaining: Adding More Methods to the ...
    - Method Chaining in PHP 5
    - The Role of Interfaces in Applying the Depen...
    - Dependency Injection: Using a Setter Method ...
    - Using a Model Class with the Dependency Inje...
    - Injecting Objects Using Setter Methods with ...
    - Injecting Objects by Constructor with the De...
    - The Dependency Injection Design Pattern in P...
    - Performing Inferential Statistical Analysis ...
    - Performing Descriptive Statistical Analysis ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    Stay green...Green IT