Re: PHP5: Exceptions must valid objects that are derived from class Exception?

From: Date: Sun, 22 Feb 2004 16:44:43 +0000
Subject: Re: PHP5: Exceptions must valid objects that are derived from class Exception?
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-8050@lists.php.net to get a copy of this message
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? /Erik

« previous php.internals (#8050) next »