Re: Exceptions and Errors

From: Date: Mon, 12 Apr 2004 15:07:43 +0000
Subject: Re: Exceptions and Errors
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-9063@lists.php.net to get a copy of this message
On Apr 12, 2004, at 10:58 AM, Adam Maccabee Trachtenberg wrote:
On Mon, 12 Apr 2004, Ilia Alshanetsky wrote:
There is 1 problem with this approach. Currently an uncaught exceptions results in a fatal error (E_ERROR) meaning that if a particular method throws an exceptions it MUST be caught otherwise the script will terminate. Having to wrap some methods inside exceptions can be extremely frustrating since you may want to allow those methods to fail.
Yes. This sucks. Maybe PHP should only issue exceptions for problems of E_WARNING severity. An exception is an "Exceptional Event." If you have an E_NOTICE or E_STRICT then that's an informational event, not a exceptional one.
I'm fine with this, but it's really just a documentation problem, right? Your method can still fail, you just need to try/catch around it. try { $obj->bornToFail(); } catch(Exception $e){} Uglier than just swallowing a warning for sure, but still just a doc problem.
Either that or uncaught exceptions should be E_WARNINGs instead of E_ERRORs. (I don't want to introduce Java's checked versus unchecked exception concept.)
-1. George

« previous php.internals (#9063) next »