|
4 | 4 |
|
5 | 5 | use App\Event\EventDispatcher;
|
6 | 6 | use App\Event\GitHubEvent;
|
7 |
| -use Psr\Log\LoggerAwareInterface; |
8 |
| -use Psr\Log\LoggerAwareTrait; |
| 7 | +use Psr\Log\LoggerInterface; |
9 | 8 | use Symfony\Component\HttpFoundation\Request;
|
10 | 9 | use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
11 | 10 | use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
|
16 | 15 | *
|
17 | 16 | * @author Jules Pietri <jules@heahprod.com>
|
18 | 17 | */
|
19 |
| -class GitHubRequestHandler implements LoggerAwareInterface |
| 18 | +class GitHubRequestHandler |
20 | 19 | {
|
21 |
| - use LoggerAwareTrait; |
22 | 20 | private $dispatcher;
|
23 | 21 | private $repositoryProvider;
|
24 |
| - private $container; |
| 22 | + private $logger; |
25 | 23 |
|
26 |
| - public function __construct(EventDispatcher $dispatcher, RepositoryProvider $repositoryProvider) |
| 24 | + public function __construct(EventDispatcher $dispatcher, RepositoryProvider $repositoryProvider, LoggerInterface $logger) |
27 | 25 | {
|
28 | 26 | $this->dispatcher = $dispatcher;
|
29 | 27 | $this->repositoryProvider = $repositoryProvider;
|
| 28 | + $this->logger = $logger; |
30 | 29 | }
|
31 | 30 |
|
32 | 31 | /**
|
@@ -67,7 +66,10 @@ public function handle(Request $request)
|
67 | 66 | try {
|
68 | 67 | $this->dispatcher->dispatch($event, 'github.'.$eventName);
|
69 | 68 | } catch (\Exception $e) {
|
70 |
| - throw new \RuntimeException(sprintf('Failed dispatching "%s" event for "%s" repository.', (string) $eventName, $repository->getFullName()), 0, $e); |
| 69 | + $message = sprintf('Failed dispatching "%s" event for "%s" repository.', (string) $eventName, $repository->getFullName()); |
| 70 | + $this->logger->error($message, ['exception' => $e]); |
| 71 | + |
| 72 | + throw new \RuntimeException($message, 0, $e); |
71 | 73 | }
|
72 | 74 |
|
73 | 75 | $responseData = $event->getResponseData();
|
|
0 commit comments