SB>> The lack of a common interface of thrown exceptions hinders the SB>> development of applications like PHPUnit that need to be able to SB>> work with every possible exception.
Don't we have a way to catch any exception in the language yet?
--
Stanislav Malyshev, Zend Products Engineer
stas@zend.com http://www.zend.com/ +972-3-6139665 ext.109
SB>> The lack of a common interface of thrown exceptions hinders the SB>> development of applications like PHPUnit that need to be able to SB>> work with every possible exception.
Don't we have a way to catch any exception in the language yet?
If you want to catch any exception, just require people to define their exceptions as extending the "exception" class, if they wish to use phpunit. We shouldn't have an engine-level straightjacket on exceptions (more of a response to sebastian's mail than to stas').
-Sterling
Quoted text · 4 lines
--
Stanislav Malyshev, Zend Products Engineer
stas@zend.com http://www.zend.com/ +972-3-6139665 ext.109 --
"Whether you think you can or think you can't -- you are right." - Henry Ford
We need to do at least one of the following:
- Force all exceptions to be descendants of a builtin Exception class
- Force all exceptions to implement a Throwable interface
- Provide a catch-all syntax to the language for exception handling.
This is extremely important for people writing such things as SOAP or RPC servers that want to keep their implementations as robust as possible.
While we are at it, lets have the call to undefined method fatal error and the type-hint checking raise exceptions too; procedural code will still bail out if it doesn't catch the exception, while robust OO coders will be able to act on the event and handle it gracefully.
--Wez.
SB>> The lack of a common interface of thrown exceptions hinders the SB>> development of applications like PHPUnit that need to be able to SB>> work with every possible exception.
Don't we have a way to catch any exception in the language yet?
If you want to catch any exception, just require people to define their exceptions as extending the "exception" class, if they wish to use phpunit. We shouldn't have an engine-level straightjacket on exceptions (more of a response to sebastian's mail than to stas').
Quoted text · 6 lines
We need to do at least one of the following:
- Force all exceptions to be descendants of a builtin Exception class
- Force all exceptions to implement a Throwable interface
- Provide a catch-all syntax to the language for exception handling.
This is extremely important for people writing such things as SOAP or RPC servers that want to keep their implementations as robust as possible.
While we are at it, lets have the call to undefined method fatal error and the type-hint checking raise exceptions too; procedural code will still bail out if it doesn't catch the exception, while robust OO coders will be able to act on the event and handle it gracefully.
As mentioned over IRC.
Why do this with Throwable (which raises the WTF factor), why not just add a generic default case:
try {
throw new Bar;
} catch ($e) {
// do stuff with the exception
}
sure introspection will suffer, but I'm against anything that forces a developer into a contract they may not want to make.
-Sterling
--
"Science is like sex: sometimes something useful comes out, but that is not the reason we are doing it." - Richard Feynman
Wez Furlong wrote:
This is extremely important for people writing such things as SOAP or RPC servers that want to keep their implementations as robust as possible.
I was thinking about those, too.
While we are at it, lets have the call to undefined method fatal error and the type-hint checking raise exceptions too; procedural code will still bail out if it doesn't catch the exception, while robust OO coders will be able to act on the event and handle it gracefully.
Amen,
Sebastian
--
Sebastian Bergmann
http://sebastian-bergmann.de/ http://phpOpenTracker.de/
Did I help you? Consider a gift: http://wishlist.sebastian-bergmann.de/
At 16:24 23.03.2003, Stanislav Malyshev wrote:
SB>> The lack of a common interface of thrown exceptions hinders the SB>> development of applications like PHPUnit that need to be able to SB>> work with every possible exception.
Don't we have a way to catch any exception in the language yet?
For me it sounds like Sebastian wants to write only one catch handler but that's
not the point of designing with exceptions. Also the base class concept Sterling
did is much more powerfull than an interface based concept. Simply because a user designed class cannot access the source information in such a good way than the base class can.
marcus