#33612 [Bgs]: Uncaught exceptions do not always give an error
| From: | james at academicsuperstore dot com | Date: | Fri, 08 Jul 2005 14:35:27 +0000 |
| Subject: | #33612 [Bgs]: Uncaught exceptions do not always give an error | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969368999@lists.php.net to get a copy of this message | ||
ID: 33612
User updated by: james at academicsuperstore dot com
Reported By: james at academicsuperstore dot com
Status: Bogus
Bug Type: Documentation problem
Operating System: Debian -stable
PHP Version: 5.0.4
New Comment:
That's the point though. I want a "compile" time error so to speak.
Any uncaught throws even if not hit at run time should error out. In
java/c++ it is not valid to have code which throws an exception without
a matching catch. Or for that matter can the ZendCodeAnalyzer be
updated with this behavior?
Previous Comments:
------------------------------------------------------------------------
[2005-07-08 09:05:10] derick@php.net
Erm, you have an if(0) before your throw... of course the throw will
not even be done now...
------------------------------------------------------------------------
[2005-07-08 00:30:16] james at academicsuperstore dot com
I re-read the documentation. This is non-obvious based on the docs.
In fact it is exactly the opposite behavior from java and c++ which is
why I assume it is a bug. If the programmer fails to catch exceptions
and a corner case doesn't come up until a site is deployed there is
nothing the programmer can do. In the event that php always informed
you via a notice or some other method that you forgot to catch an
exception then this issue would not come up.
------------------------------------------------------------------------
[2005-07-08 00:16:30] tony2001@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
------------------------------------------------------------------------
[2005-07-08 00:01:04] james at academicsuperstore dot com
Description:
------------
In the event at run time an uncaught exception is found then there is a
fatal error. However, in the event that there are uncaught exceptions
that are not executed such as in the reproduce code there is not even a
notice.
Reproduce code:
---------------
<?
error_reporting(2047 | E_STRICT);
if (0)
throw new Exception("foo");
?>
Expected result:
----------------
Fatal error: Uncaught exception 'Exception' with message 'foo' in
/home/james/html/live_web/test.php:5 Stack trace: #0
Actual result:
--------------
No messages at all.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=33612&edit=1