Including class of Exception in exception message
| From: | C Drozdowski | Date: | Sat, 09 Apr 2005 15:27:43 +0000 |
| Subject: | Including class of Exception in exception message | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-212724@lists.php.net to get a copy of this message | ||
I'm using Exceptions and variously handling them in try..catch blocks or defaulting to my set_exception_handler handler.
When I create an Exception I'd like to prepend the class of the Exception to the message. Can this be done with code or do I have to hard code the name of the Exception class into the message every time I throw the exception?
For Example:
I'd like to turn this...
throw new myException("myException: So this is it, we're going to die");
into...
throw new myException( CODE . ": So this is it, we're going to die");
where CODE is some php code that refers to the class of the exception being thrown.