Skip to content

Commit 235a883

Browse files
authored
Merge pull request #13 from mantassimkunas/exception-formatting
Pass exception in the context
2 parents c97bf58 + 8960050 commit 235a883

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/Worker/RabbitMqWorker.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ public function processJob(JobInterface $job, QueueInterface $queue): int
5454
} catch (Throwable $exception) {
5555
if ($this->retryCounter->canRetry($job, $queue->getName())) {
5656
$queue->bury($job);
57-
$this->logger->warning($exception);
57+
$this->logger->warning($exception->getMessage(), ['exception' => $exception]);
5858

5959
return ProcessJobEvent::JOB_STATUS_FAILURE_RECOVERABLE;
6060
}
6161

6262
$queue->delete($job);
63-
$this->logger->error($exception);
63+
$this->logger->error($exception->getMessage(), ['exception' => $exception]);
6464

6565
return ProcessJobEvent::JOB_STATUS_FAILURE;
6666
}

tests/Worker/RabbitMqWorkerTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ public function testProcessJobWhenCanRetry(): void
7676
$originalException = new TypeError('some error');
7777

7878
$this->job->method('execute')->willThrowException($originalException);
79-
$this->logger->expects($this->once())->method('warning')->with($originalException);
79+
$this->logger->expects($this->once())->method('warning')->with(
80+
'some error',
81+
['exception' => $originalException],
82+
);
8083

8184
$this->messageRetryCounter->method('canRetry')->willReturn(true);
8285
$this->queue->expects($this->once())->method('bury');

0 commit comments

Comments
 (0)