Skip to content

Commit

Permalink
Merge pull request #19 from skwi/fix-exceptions
Browse files Browse the repository at this point in the history
🐛 Fix Exception event subscriber for symfony 5.0+
  • Loading branch information
CheapHasz authored Jan 26, 2021
2 parents ad6d45c + 4c20c10 commit 3cf8fd6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"php": "^7.1",
"elasticsearch/elasticsearch": "^5.2 || ^6.0",
"ruflin/elastica": "^6.0 || ^7.0",
"symfony/http-kernel": "^3.4 || ^4.1 || >=5.1.5",
"symfony/http-kernel": "^4.3 || >=5.1.5",
"symfony/dependency-injection": "^4.2 || ^5.0",
"symfony/web-profiler-bundle": "^4.2 || ^5.0",
"symfony/config": "^4.2 || ^5.0",
Expand Down
12 changes: 5 additions & 7 deletions src/EventSubscriber/ResponseExceptionSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

use Elastica\Exception\ResponseException as ElasticaResponseException;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpFoundation\Response;
use Novaway\ElasticsearchBundle\Exception\Response\ResponseException;
Expand All @@ -20,15 +20,13 @@ public static function getSubscribedEvents()
]
];
}

public function process(GetResponseForExceptionEvent $event)
public function process(ExceptionEvent $event)
{
$exception = $event->getException();
$exception = $event->getThrowable();
if (!$exception instanceof ElasticaResponseException) {
return;
}

$response = new ResponseException($exception->getRequest(), $exception->getResponse());
$event->setException($response);
$event->setThrowable($response);
}
}
}

0 comments on commit 3cf8fd6

Please sign in to comment.