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");
Output: Fatal error: Exception thrown without a stack frame in Unknown on line 0
The best way I have found to avoid this is to wrap up everything in the exception handler in a try/catch block.
function exception_handler($e)
{
try
{
// ... normal exception stuff goes here
print $undefined; // This is the underlying problem
}
catch (Exception $e)
{
print get_class($e)." thrown within the exception handler. Message: ".$e->getMessage()." on line ".$e->getLine();
}
}
Output: ErrorException thrown within the exception handler. Message: Undefined variable: undefined on line 14
This speeds up debugging and offers some scalability to any other exceptions accidentally thrown within the exception handler.
Another solution is to restore the error handler at the beginning of the exception handler. While this is a silver bullet in terms of avoiding the ErrorExceptions, debugging messages then rely on the error_reporting() level and the display_errors directive. Why mention this? It might be preferable for production code since we care more about hiding errors from users than convenient debugging messages.
- так что можно попытаться отключить переопределение обработчика с тем, чтобы понять, откуда вызывается исключение.
----- Есть в мире две бесконечные вещи - это Вселенная и человеческая глупость. Но насчет первой .. я не уверен.
Shtorm_sai
Отправлено: 27 Января, 2012 - 18:51:23
Частый гость
Покинул форум
Сообщений всего: 135
Дата рег-ции: Янв. 2011 Откуда: Новосибирск, Россия
throw new TinyMVC_ExceptionHandler($errstr,$errno,$errno,$errfile,$errline);
}
}
Хм... и как это исправить, какие могут быть варианты?
EuGen
Отправлено: 27 Января, 2012 - 18:56:07
Профессионал
Покинул форум
Сообщений всего: 9095
Дата рег-ции: Июнь 2007 Откуда: Berlin
Помог: 707 раз(а)
Ну так отключите переопределение (то есть закомментируйте то, где определяется специальный обработчик исключений). После этого то исключение, что порождает Вам Fatal error - будет обрабатываться стандартно и Вы увидите его отладочный путь, после чего станет ясно где, что и почему его вызвало.
----- Есть в мире две бесконечные вещи - это Вселенная и человеческая глупость. Но насчет первой .. я не уверен.
Shtorm_sai
Отправлено: 28 Января, 2012 - 06:04:38
Частый гость
Покинул форум
Сообщений всего: 135
Дата рег-ции: Янв. 2011 Откуда: Новосибирск, Россия
Все гости форума могут просматривать этот раздел. Только зарегистрированные пользователи могут создавать новые темы в этом разделе. Только зарегистрированные пользователи могут отвечать на сообщения в этом разделе.