> As Rasmus said, we discussed this issue lately.  We agreed that errors that 
> can't be handled automatically (fatal errors), but don't leave the 
> scripting engine in an unstable state, should be allowed to be handled by 
> users.  The example there was also calls to undefined functions.
> 
> Unfortunately, calls to undefined functions do (or may) leave the engine in 
> an unstable state, as far as I recall.  I didn't get to review the code 
> since then - so it may or may not be safe to let users trap this error.
> 
> At any rate, we won't use E_USER_ERROR for this type of fatal, yet 
> recoverable errors - but a new error level (E_TRAPPABLE_ERROR or something 
> like that).
> 

This probably sounds kind of hackish (and off topic for the current
thread) but if you were to allow users to catch undefined functions, would
it be possible to then also allow the error handler to return a value to
be returned to the caller of said undefined function? It's basically a
rather hackish method of allowing autoload of includes/libraries,
something to the effect of:

function error_handler($errno,$errmsg,$file,$line,$fcall,$args)
{
        if ($errno == E_UNDEFINED_FUNCTION) {
                // You get the idea here ...
                if (find_function_in_autoload_stuff($fcall))
                        return call_user_function_array($fcall,$args);
                else
                        print_error_message();
        } else {
                do_other_stuff();
        }
}

set_error_handler("error_handler");

$a = undefined_function(); /* Now if the error handler can find the
                                function, it transparently loads the
                                required files and the script never
                                notices the difference. Otherwise,
                                we never execute beyond this point. */

I know that my example is horribly oversimplified, but it should get the
point across..

Chris


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to