Re: PHP5: Exceptions must valid objects that are derived from class Exception?
| From: | Markus Fischer | Date: | Sun, 22 Feb 2004 18:08:00 +0000 |
| Subject: | Re: PHP5: Exceptions must valid objects that are derived from class Exception? | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-8054@lists.php.net to get a copy of this message | ||
On Sun, Feb 22, 2004 at 05:44:43PM +0100, Erik Franzén wrote :
> Markus Fischer wrote:
> > The catch-all helps catching any type of exception, _given that_ it
> > is derived from class Exception. The motivation behind it, and this
> > makes sense to me, I'm pro this behaviour, is, that this way the
> > interface of the Exception class is well defined. You can always
> > count that you have the methods getMessage, getCode, getFile,
> > getTraceAsString, etc. Which is IMO good.
> >
> > - Markus
>
> With this behavior you force the developer to use the exception class.
> You cannot use your own class because PHP will trigger an error if you do.
>
> However, you can of course extend the exception class with your own
> class, but you cannot replace the default methods (getMessage etc) since
> they are final.
>
> I don't like this, since you are forced to use the built in exception
> class which also has final methods. Where has the feeling of freedom gone?
Your point is true. Why getMessage() is final I don't know. My
development with PHP5 has only started a month ago, but yet haven't
run in any limitations by this although I'm making heavy use of
Exceptions and Object-Code.
- Markus