Use exception processor
This commit is contained in:
@ -10,11 +10,14 @@ class Exception implements ProcessorInterface
|
||||
public function __invoke(LogRecord $record): LogRecord
|
||||
{
|
||||
$context = $record->context;
|
||||
foreach ($context as $key => $value) {
|
||||
if (is_a($value, Throwable::class)) {
|
||||
$exception = $value;
|
||||
$output = $this->processException($exception);
|
||||
$context[$key] = $output;
|
||||
$changed = false;
|
||||
array_walk_recursive($context, function (&$item) use (&$changed) {
|
||||
if (is_a($item, Throwable::class)) {
|
||||
$item = $this->processException($item);
|
||||
$changed = true;
|
||||
}
|
||||
});
|
||||
if ($changed) {
|
||||
$new_record = new LogRecord(
|
||||
$record->datetime,
|
||||
$record->channel,
|
||||
@ -25,7 +28,6 @@ class Exception implements ProcessorInterface
|
||||
);
|
||||
$record = $new_record;
|
||||
}
|
||||
}
|
||||
if (is_a($record->message, Throwable::class)) {
|
||||
$exception = $record->message;
|
||||
$output = $this->processException($exception);
|
||||
|
@ -79,13 +79,7 @@ class Queue extends Ideal\Service
|
||||
try {
|
||||
$this->jobService->update($job);
|
||||
} catch (Update $exception) {
|
||||
$this->logger->error($exception->getMessage(), ['job' => $job, 'exception' => [
|
||||
'code' => $exception->getCode(),
|
||||
'message' => $exception->getMessage(),
|
||||
'file' => $exception->getFile(),
|
||||
'line' => $exception->getLine(),
|
||||
'trace' => $exception->getTraceAsString(),
|
||||
]]);
|
||||
$this->logger->error($exception->getMessage(), ['job' => $job, 'exception' => $exception]);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ class Reservation extends Ideal\Service\API
|
||||
$this->reservationRepository->getConnection()->getPDO()->commit();
|
||||
}
|
||||
} catch (PDOException $exception) {
|
||||
$this->logger->warning($exception->getMessage(), ['exception' => $exception->getTraceAsString()]);
|
||||
$this->logger->warning($exception->getMessage(), ['exception' => $exception]);
|
||||
if ($this->reservationRepository->getConnection()->getPDO()->inTransaction()) {
|
||||
$this->reservationRepository->getConnection()->getPDO()->rollBack();
|
||||
}
|
||||
|
Reference in New Issue
Block a user