From:             benjcarson at digitaljunkies dot ca
Operating system: Linux
PHP version:      5CVS-2004-02-16 (dev)
PHP Bug Type:     Zend Engine 2 problem
Bug description:  Exception not caught if more than two catch blocks are used

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 bug report at http://bugs.php.net/?id=27283&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=27283&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=27283&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=27283&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=27283&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=27283&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=27283&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=27283&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=27283&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=27283&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=27283&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=27283&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=27283&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27283&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=27283&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=27283&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=27283&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=27283&r=float

Reply via email to