Re: Exception Handling
| From: | James Colannino | Date: | Fri, 01 Jun 2012 15:08:29 +0000 |
| Subject: | Re: Exception Handling | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-318081@lists.php.net to get a copy of this message | ||
On 06/01/12 07:30, marco@behnke.biz wrote:
James Colannino<crankycyclops@gmail.com> hat am 1. Juni 2012 um 16:25 geschrieben:Hey Marco, Thanks for the reply! That was the first thing I checked. class Database_Exception extends \FuelException {} class Fuel_Exception extends \Exception {} It's extending Exception, as expected. Also, can you throw classes that don't extend Exception? It was always my understanding that doing so would cause a fatal error. JamesHey guys, Haven't posted in a long time... Happy Memorial Day! I have an issue with exception handling. I'm using a framework that throws a "Database_Exception" object. I was expecting catch (Exception $var) to be sufficient to catch this, but it doesn't. I have to do catch (Database_Exception $var) to make it work. I've been reading that Exception should be sufficient, since every exception object is a child class of Exception. Did this perhaps change in 5.4? I think it was working properly in 5.3, but I'm not sure.Look at the definition of "Database_Exception" and see if it extends Exception, I'll guess it doesn't. Nothing changed in PHP 5.4 to that.