php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #33612 Uncaught exceptions do not always give an error
Submitted: 2005-07-08 00:01 UTC Modified: 2005-07-08 16:35 UTC
From: james at academicsuperstore dot com Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 5.0.4 OS: Debian -stable
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: james at academicsuperstore dot com
New email:
PHP Version: OS:

 

 [2005-07-08 00:01 UTC] 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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-07-08 00:16 UTC] 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:30 UTC] 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 09:05 UTC] 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 16:35 UTC] james at academicsuperstore dot com
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?
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 10 21:01:34 2025 UTC