Re: RFC: Replacing errors with Exceptions

From: Date: Wed, 29 Jul 2009 21:33:18 +0000
Subject: Re: RFC: Replacing errors with Exceptions
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-45130@lists.php.net to get a copy of this message
Le Fri, 24 Jul 2009 15:23:21 +0200, user a écrit : > I published a (work in progress) RFC today about replacing certain > errors with exceptions. I know that there already was something similiar > on the php6dev blog, but this is not completly the same, so awating your > comments: > > http://wiki.php.net/rfc/errors_as_exceptions I'm agree for replacing error by exception. Even if this not a good idea, i think there is a big problem with error gesture into php. Exemple : http://fr3.php.net/manual/en/function.simplexml-load-string.php The simplexml_load_string documentation says : « Return Values Returns an object of class SimpleXMLElement with properties containing the data held within the xml document. On errors, it will return FALSE. » That's not true, on error, yes the fonction return false but simplexml_load_string return also an error on not xml formated string. The result is it's impossible to use this function without @ statement. This can be considered as a bug and change the documentation or remove the error in simplexml_load_string will fix the bug. In fact, with exception in place of error, the same problem had a simple solution with try / catch elements. Exception in place of error's make life easy for developpers because if developper want, he can do something by catching exception before the program interrupt.

« previous php.internals (#45130) next »