« Return to Thread: Error handling

Re: Error handling

by Jeroen Keppens :: Rate this Message:

Reply to Author | View in Thread

Typically when you catch exceptions, you can check on the class type.  
You usually don't check on the message. So empty classes, provide the  
possibility for different messages for the same type of exception,  
while retaining the option to check for the type of exception.

try {
    // Code
} catch (My_Db_Exception $e) {
     // Bla bla
} catch (My_File_Exception $e) {
     // Bla bla something else
} catch (Exception $e) {
     // Default bla bla
}

If you have something specific you want to check on, make it into a  
separate class.

Wkr
Jeroen

On 01 Jul 2009, at 23:06, Ed Lazor wrote:

> Is it best to create your own exception classes and build them with
> built-in logging or do you recommend a different approach?  I'm
> noticing that the zend exception classes are all empty - is that
> because they're just used to define different types of exceptions?
>
> -Ed
>

 « Return to Thread: Error handling