mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Added usage of configured error handler instead of hard coded. Moved try/catch block to where its nessecary. Set Configure::write('Error.trace', false) since its useless with internals. Addition to #1707 .
This commit is contained in:
parent
1b14887e3a
commit
d8a614e112
1 changed files with 21 additions and 20 deletions
|
@ -107,7 +107,6 @@ class ErrorHandler {
|
|||
* @see http://php.net/manual/en/function.set-exception-handler.php
|
||||
*/
|
||||
public static function handleException(Exception $exception) {
|
||||
try {
|
||||
$config = Configure::read('Exception');
|
||||
if (!empty($config['log'])) {
|
||||
$message = sprintf("[%s] %s\n%s",
|
||||
|
@ -122,16 +121,18 @@ class ErrorHandler {
|
|||
list($plugin, $renderer) = pluginSplit($renderer, true);
|
||||
App::uses($renderer, $plugin . 'Error');
|
||||
}
|
||||
try {
|
||||
$error = new $renderer($exception);
|
||||
$error->render();
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getMessage()."\nCall Stack:\n".$e->getTraceAsString();
|
||||
ErrorHandler::handleError(
|
||||
E_ERROR,
|
||||
$message,
|
||||
$e->getFile(),
|
||||
$e->getLine()
|
||||
set_error_handler(Configure::read('Error.handler')); // Should be using configured ErrorHandler
|
||||
Configure::write('Error.trace', false); // trace is useless here since it's internal
|
||||
$message = sprintf("[%s] %s\n%s", // Keeping same message format
|
||||
get_class($e),
|
||||
$e->getMessage(),
|
||||
$e->getTraceAsString()
|
||||
);
|
||||
trigger_error($message, E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue