Re: exception policy for core
| From: | Lukas Kahwe Smith | Date: | Thu, 18 Oct 2007 22:29:15 +0000 |
| Subject: | Re: exception policy for core | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-32866@lists.php.net to get a copy of this message | ||
On 18.10.2007, at 12:29, Johannes Schlüter wrote:
Hi, On Thu, 2007-10-18 at 11:45 +0400, Antony Dovgal wrote: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, LukasOn 17.10.2007 20:09, Lukas Kahwe Smith wrote: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.Hi, I remember that we discussed the question of exception throwing from core in the very early days of php 5, when the suggestion of turning all errors into exceptions first came up. I remember that we decided that exceptions should only be thrown from core on constructor errors by default. Along the lines of PDO, extensions could allow users to explicitly enable an exception mode.First of all, I have to say that I see nothing wrong in using exceptions. Second, I see nothing wrong in using exceptions _in OO extensions_. And finally, I don't like the idea of having a special function in each and every extension to control it's error level. PDO was built this way from the very beginning, but making this some kind of standard would be a mistake IMO. You may not like exceptions, but that doesn't make them less useful.