RE: Exception Handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----Original Message-----
From: James Colannino [mailto:crankycyclops@xxxxxxxxx] 
Sent: Friday, June 01, 2012 11:14 AM
To: PHP-General List
Subject: Re:  Exception Handling

Hey Mike,

Thanks for the reply!  I saw this comment in the documentation
(http://www.php.net/manual/en/language.exceptions.extending.php) -- it's
the first one:

"|It's important to note that subclasses of the Exception class will be
caught by the default Exception handler"

Of course, I haven't tested the code they posted.  I'll do that tonight
and confirm or deny the expected result.

James
|

Well look at that..

class James_Exception extends \Exception{
	function __construct($message){
		parent::__construct($message);
	}
}

try{
	throw new James_Exception('Testing Exception Catch-All');
}
catch(Exception $e){
	print_r($e);	
}

Output:

"James_Exception Object
(
    [message:protected] => Testing Exception Catch-All..."

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux