A documentation issue regarding catching exceptions
| From: | Mikael Nordfeldth | Date: | Wed, 16 Oct 2013 23:02:24 +0000 |
| Subject: | A documentation issue regarding catching exceptions | ||
| Groups: | php.doc | ||
| Request: | Send a blank email to phpdoc+get-969384672@lists.php.net to get a copy of this message | ||
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."
--
Mikael Nordfeldth
http://blog.mmn-o.se/
XMPP/mail: mmn@hethane.se