ID:               32207
 User updated by:  php-bug at zulan dot net
 Reported By:      php-bug at zulan dot net
-Status:           Feedback
+Status:           Open
 Bug Type:         Zend Engine 2 problem
 Operating System: Win32
 PHP Version:      5.0.3
 New Comment:

I get the same results with the latest cvs

PHP Version 5.1.0-dev
Build Date      Mar 6 2005 16:25:25


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

[2005-03-06 19:56:17] jowag89 at gmx dot ch

Here's the result of running it on my Linux-Box.
php version: php5-200503061730
Catched exception outside of
test():
test(missing_file.php): failed to open stream: No such file or
directory
Catched exception inside of
test():
fopen() expects at least 2 parameters, 1 given

Looks like the problem is still there in the cvs version.

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

[2005-03-06 19:19:31] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip



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

[2005-03-06 19:13:55] php-bug at zulan dot net

Description:
------------
When include or require (_once) triggers an error it is triggered in a
different "scope" as other errors, like an above funktion or the main
dummy function. Therfore when the error is handled by throwing an
exception instead this will give confusing results including uncaught
exceptions that actually should be caught.

Reproduce code:
---------------
<?php
function __error_handler($type, $message, $file, $line, $context)
{
    throw new Exception($message,$type);
}
set_error_handler('__error_handler',E_ALL);

function test($t) {
    try
    {
     /* Both should trigger the error in the same context */
        if ($t)
            include('missing_file.php');
        else
            fopen('forgot_parameter');
    }
    catch (Exception $e)
    {
        echo("Catched exception inside of
test():\n".$e->getMessage()."\n");
    }
}

try
{
    test(true);
}
catch (Exception $e)
{ /* So we do not get a nasty uncaught exception error */
     echo("Catched exception outside of
test():\n".$e->getMessage()."\n");
}

try
{
    test(false);
}
catch (Exception $e)
{ /* So we do not get a nasty uncaught exception error */
     echo("Catched exception outside of
test():\n".$e->getMessage()."\n");
}
?>

Expected result:
----------------
Catched both exceptions inside of test

Actual result:
--------------
Catches the fopen error inside but the include error outside of test.


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


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

Reply via email to