Re: exception policy for core
| From: | Lukas Kahwe Smith | Date: | Fri, 19 Oct 2007 06:39:51 +0000 |
| Subject: | Re: exception policy for core | ||
| References: | 1 2 3 4 | Groups: | php.internals php.internals |
| Request: | Send a blank email to internals+get-32872@lists.php.net to get a copy of this message | ||
On 19.10.2007, at 02:20, Larry Garfield wrote:
On Thursday 18 October 2007, Lukas Kahwe Smith wrote:Well that sounds like a bug and not like a "feature" of exceptions. Or are you implying that the added complexity of this switch makes it harder to write bug free code. I do image that its a bit annoying to have to write tests to cover all the error modes. regards, LukasI've actually had issues in the past with PDO and non-exception error-mode handling. I had queries that were running fine but when I checked the error value it gave a non-OK value. (I forget what off hand.) As soon as I switched to exceptions, it worked perfectly. I believe this was under 5.2.1. --The possibility of changing the error mode at run-time makes it quite hard to read code. Since you always have to check the error mode of the object you're currently looking at. Therefore I think we should avoid adding more of these switches in future - especially on an per-object basis.Well I agree that this can be problematic. In the case of PDO one might be passing a PDO instance to various libraries, which may rely on exceptions being thrown or not. Personally I would not mind not throwing exceptions for anything but constructor errors (actually I think even those should be avoided), but that switch in PDO seemed like an acceptable balance. regards, Lukas