parent
d5b0102945
commit
f731918f43
@ -0,0 +1,3 @@ |
||||
import makeService from './api'; |
||||
|
||||
export default makeService('resource_links'); |
||||
@ -0,0 +1,24 @@ |
||||
<?php |
||||
|
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
namespace Chamilo\CoreBundle\Security; |
||||
|
||||
use Symfony\Component\HttpFoundation\JsonResponse; |
||||
use Symfony\Component\HttpKernel\Event\ExceptionEvent; |
||||
use Symfony\Component\HttpKernel\Exception\HttpException; |
||||
|
||||
final class HTTPExceptionListener |
||||
{ |
||||
public function onKernelException(ExceptionEvent $event): void |
||||
{ |
||||
$exception = $event->getThrowable(); |
||||
if (! ($exception instanceof HttpException) || strpos($event->getRequest()->getRequestUri(), '/api/') === false) { |
||||
return; |
||||
} |
||||
|
||||
$response = new JsonResponse(['error' => $exception->getMessage()]); |
||||
$response->setStatusCode($exception->getStatusCode()); |
||||
$event->setResponse($response); |
||||
} |
||||
} |
||||
Loading…
Reference in new issue