ID:               27283
 Comment by:       myle34 at hotmail dot com
 Reported By:      benjcarson at digitaljunkies dot ca
 Status:           Verified
 Bug Type:         Zend Engine 2 problem
 Operating System: *
 PHP Version:      5CVS-2004-03-15
 New Comment:

Not only do I have the same problem, but when your code is executed
several times, Apache crashes on Windows XP SP1 with Apache 2.0.48.



However, I have found that ALL exception related code crashes after
several page refreshes. Additionally, the more complex the exception
code, the fewer page refreshes it takes to crash.


Previous Comments:
------------------------------------------------------------------------

[2004-03-06 14:04:00] benjcarson at digitaljunkies dot ca

For now we've had to use this workaround:



<?php

class Ex1 extends Exception { }

class Ex2 extends Exception { }

class Ex3 extends Exception { }



try {

  throw new Ex3("Ex3");



} catch (Exception $e) {



  if ($e instanceof Ex1) 

    echo ("Ex1: " . $e->getMessage() . "\n");

  else if ($e instanceof Ex2)

    echo ("Ex2: " . $e->getMessage() . "\n");

  else if ($e instanceof Ex3)

    echo ("Ex3: " . $e->getMessage() . "\n");

  else

    echo ("Exception: " . $e->getMessage() . "\n");

}

------------------------------------------------------------------------

[2004-02-16 21:09:43] benjcarson at digitaljunkies dot ca

Description:
------------
If an exception is thrown within a try block and more than two catch
blocks follow, the exception may not be caught.  If the exception
matches either of the first two catch blocks then the exception will be
caught.  However, if the exception does not match the first two catch
blocks, it will skip any remaining catch blocks and remain uncaught.



In the code below, the exception is caught properly if the second catch
block is commented out.  Once it is included again though, the
exception is not caught.

Reproduce code:
---------------
<?php

class Ex1 extends Exception { }

class Ex2 extends Exception { }

class Ex3 extends Exception { }



try {

  throw new Ex3("Ex3");



} catch (Ex1 $e) {

  echo ("Ex1: " . $e->getMessage() ."\n");



} catch (Ex2 $e) {

  echo ("Ex2: " . $e->getMessage() ."\n");

  

} catch (Exception $e) {  // Note: trying to catch Ex3 also fails

  echo ("Exception: " . $e->getMessage() . "\n");

}

exit(0);

?>

Expected result:
----------------
Execption: Ex3



Actual result:
--------------
Fatal error: Uncaught exception 'Ex3' with message 'Ex3'
exception.php:8

Stack trace:

#0 {main}

  thrown in exception.php on line 8




------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=27283&edit=1

Reply via email to