forked from swarrot/swarrot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExceptionCatcherProcessor.php
46 lines (39 loc) · 1.08 KB
/
ExceptionCatcherProcessor.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
namespace Swarrot\Processor\ExceptionCatcher;
use Swarrot\Broker\Message;
use Swarrot\Processor\ProcessorInterface;
use Psr\Log\LoggerInterface;
class ExceptionCatcherProcessor implements ProcessorInterface
{
/**
* @var ProcessorInterface
*/
protected $processor;
/**
* @var LoggerInterface
*/
protected $logger;
public function __construct(ProcessorInterface $processor, LoggerInterface $logger = null)
{
$this->processor = $processor;
$this->logger = $logger;
}
/**
* {@inheritDoc}
*/
public function process(Message $message, array $options)
{
try {
return $this->processor->process($message, $options);
} catch (\Exception $e) {
$this->logger and $this->logger->error(
'[ExceptionCatcher] An exception occurred. This exception have been catch.',
array(
'swarrot_processor' => 'exception',
'exception' => $e,
)
);
}
return;
}
}