Voting

: min(two, zero)?
(Example: nine)

The Note You're Voting On

Anonymous
12 years ago
As of PHP 5.4.11....

Instead of:

Output: Fatal error: Exception thrown without a stack frame in Unknown on line 0

This snippet:

<?php
function error_handler($code, $message, $file, $line)
{
if (
0 == error_reporting())
{
return;
}
throw new
ErrorException($message, 0, $code, $file, $line);
}
function
exception_handler($e)
{
// ... normal exception stuff goes here
print $undefined; // This is the underlying problem
}
set_error_handler("error_handler");
set_exception_handler("exception_handler");
throw new
Exception("Just invoking the exception handler");
?>

Now returns:

Fatal error: Uncaught exception 'ErrorException' with message 'Undefined variable: undefined' in C:\Apache2\htdocs\error\test.php:13 Stack trace: #0 C:\Apache2\htdocs\error\test.php(13): error_handler(8, 'Undefined varia...', 'C:\Apache2\htdo...', 13, Array) #1 [internal function]: exception_handler(Object(Exception)) #2 {main} thrown in C:\Apache2\htdocs\error\test.php on line 13

So it appears that exceptions thrown within exception handler now bypass exception handler.

<< Back to user notes page

To Top