Re: A documentation issue regarding catching exceptions

From: Date: Thu, 17 Oct 2013 08:44:29 +0000
Subject: Re: A documentation issue regarding catching exceptions
References: 1  Groups: php.doc 
Request: Send a blank email to phpdoc+get-969384675@lists.php.net to get a copy of this message
On 17 October 2013 00:02, Mikael Nordfeldth <mmn@hethane.se> wrote: > The documentation says: > "Normal execution (when no exception is thrown within the try block, or when > a catch matching the thrown exception's class is not present) will continue > after that last catch block defined in sequence." > > Source: http://php.net/manual/en/language.exceptions.php > > The incorrect (or perhaps confusing) statement is "Normal execution ([...] > when a catch matching the thrown exception's class is not present) will > continue after that last catch block...". > > What PHP does if there is no catch block for a thrown exception's class is > to escalate the exception to the previously calling method (to see if > there's a catch block there, or continue until it reaches the user). > > Of course, that is "normal execution" (escalating the exception), so perhaps > it is not incorrect but merely confusing? It is perhaps just me that > interprets "normal execution" as what would continue to be executed, had > there not been an exception. > > If it is merely confusing, I would suggest adding a sentence regarding the > behaviour of escalation immediately afterwards the above quote. Maybe > something like: > "Any exception for which there is no corresponding catch block will be > raised to the parent scope." > Thanks for the report, I agree this is not as clear as it could be. Please note that the mailing list isn't really the place to report this, such matters should be raised as bugs (http://bugs.php.net/) or you are also welcome to fix issues like this yourself - if you go to the page that is incorrect and click "edit" in the top right corner it will open the docbook editor which will allow you to fix the XML source yourself. If you are going to raise a bug on the bug tracker, please ensure you use the search tool to see if the issue has already been reported. As far as this particular issue goes, I see a few issues on this page (I'm 99% certain that the introduction of finally means that "Each try must have at least one corresponding catchblock." is no longer correct either) - I'm going to do some fact-checking on this and ask a few people what the best way to explain exceptions would be. Once again, thanks for the report, we always welcome people wishing to improve the documentation, but please use the bug tracker for the initial report next time :-) Thanks, Chris

« previous php.doc (#969384675) next »