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: Object-Oriented Development, Technology, Best Practices, PHP 5
Tags: exceptions, extending exceptions, nested exceptions
A great feature of PHP is the ability to throw and catch exceptions. This feature was introduced in PHP 5, and has been around for years in other languages like Python.
Exceptions make it easy to interrupt program flow in the event that something goes wrong. They allow you to customize how a program handles errors, and gracefully degrades an application. This week, we will discuss various exception handling techniques, and today we will discuss the basic dos and don’ts for exceptions.
Monday, November 9th, 2009 @ 1:00 am |
Comment (9) |
Categories: Best Practices, PHP 5, Object-Oriented Development, Technology
Tags: exceptions, exception handling, throwing exceptions