1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-03 19:57:41 +02:00

Tweaks to exception handler, refs #1012

This commit is contained in:
Jordi Boggiano
2018-06-08 20:47:04 +02:00
parent 4814446331
commit 6d79e51f91

View File

@@ -15,6 +15,7 @@ use Monolog\Handler\HandlerInterface;
use Monolog\Handler\StreamHandler; use Monolog\Handler\StreamHandler;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use Psr\Log\InvalidArgumentException; use Psr\Log\InvalidArgumentException;
use Exception;
/** /**
* Monolog log channel * Monolog log channel
@@ -346,8 +347,8 @@ class Logger implements LoggerInterface
next($this->handlers); next($this->handlers);
} }
} catch (\Exception $ex) { } catch (Exception $e) {
$this->handleException($ex, $record); $this->handleException($e, $record);
} }
return true; return true;
@@ -537,17 +538,14 @@ class Logger implements LoggerInterface
/** /**
* Delegates exception management to the custom exception handler, * Delegates exception management to the custom exception handler,
* or throws the exception if no custom handler is set. * or throws the exception if no custom handler is set.
*
* @param Exception $ex
* @param array $record
*/ */
protected function handleException(\Exception $ex, $record) protected function handleException(Exception $e, array $record)
{ {
if ($this->exceptionHandler) { if (!$this->exceptionHandler) {
call_user_func($this->exceptionHandler, $ex, $record); throw $e;
} else {
throw $ex;
} }
call_user_func($this->exceptionHandler, $e, $record);
} }
/** /**