On Thu, Feb 24, 2011 at 10:29 AM, Ferenc Kovacs <i...@tyrael.hu> wrote:
> Hi. > > it was mentioned multiple times on the list, that exceptions from php core > is prohibited. > do we have some documentation about this? > the more detailed email on this topic was from Lukas: > http://www.mail-archive.com/internals@lists.php.net/msg43237.html > > > "Generally we have decided to leave Exceptions out of core with a few > "exceptions": > > 1) errors in the constructor will throw an exception > 2) extensions may choose to offer an Exception mode (see PDO) > > I never understood why we did 1), if a constructor can fail, then a > factory should be used instead. But oh well. With 2) you are obviously also > opening a pandoras box, that is similar to using a global error handler > that turns all Notices, Warnings etc as Exception: you can easily break > code that calls various libraries .. take for example passing in a PDO > instance to one library which expects the normal error mode and another one > that enables the Exception mode. For the most part however we can conclude > that most libraries enable the Exception mode in PDO and I think you will > be hard pressed to find any PDO code example that doesn't assume that the > Exception mode is enabled. " > > every other mention about this topic is in-general prohibits the usage of > exceptions. > http://www.mail-archive.com/internals@lists.php.net/msg49637.html > http://www.mail-archive.com/internals@lists.php.net/msg44159.html > > so I would like to know, that what is the current situation, and do these > mails still holds true. > maybe things has changed. > > Tyrael > Sorry for bringing up this thread, but based on the recent mails from Derick it seems to me that there is/was some agreement that core features shouldn't throw exceptions. http://www.mail-archive.com/internals@lists.php.net/msg60631.html http://www.mail-archive.com/internals@lists.php.net/msg60635.html It was also mentioned in that thread that we already have a bunch of exceptions in spl, and some of the spl features should be in the core (or it is already in the core for example IteratorAggregate). Personally I think that OOP features should be allowed to throw Exceptions, and I think that it would still in line with the our users expectations. The only problem that I can think of is that for some stuff, we have both a procedural and an oop API, but I'm not proposing turning everything into Exceptions, but using them where appropriate.