• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

api-platform / core / 6067528200

04 Sep 2023 12:12AM UTC coverage: 36.875% (-21.9%) from 58.794%
6067528200

Pull #5791

github

web-flow
Merge 64157e578 into d09cfc9d2
Pull Request #5791: fix: strip down any sql function name

3096 of 3096 new or added lines in 205 files covered. (100.0%)

9926 of 26918 relevant lines covered (36.87%)

6.5 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.71
/src/Symfony/EventListener/ExceptionListener.php
1
<?php
2

3
/*
4
 * This file is part of the API Platform project.
5
 *
6
 * (c) Kévin Dunglas <dunglas@gmail.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11

12
declare(strict_types=1);
13

14
namespace ApiPlatform\Symfony\EventListener;
15

16
use ApiPlatform\Metadata\Error;
17
use ApiPlatform\Util\RequestAttributesExtractor;
18
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
19
use Symfony\Component\HttpKernel\EventListener\ErrorListener;
20

21
/**
22
 * Handles requests errors.
23
 *
24
 * @author Samuel ROZE <samuel.roze@gmail.com>
25
 * @author Kévin Dunglas <dunglas@gmail.com>
26
 */
27
final class ExceptionListener
28
{
29
    public function __construct(private readonly ErrorListener $errorListener)
30
    {
31
    }
84✔
32

33
    public function onKernelException(ExceptionEvent $event): void
34
    {
35
        $request = $event->getRequest();
12✔
36
        // Normalize exceptions only for routes managed by API Platform
37
        if (
38
            !((RequestAttributesExtractor::extractAttributes($request)['respond'] ?? $request->attributes->getBoolean('_api_respond', false)) || $request->attributes->getBoolean('_graphql', false))
12✔
39
        ) {
40
            return;
3✔
41
        }
42

43
        // Don't loop on errors leave it to Symfony as we could not handle this properly
44
        if (($operation = $request->attributes->get('_api_operation')) && $operation instanceof Error) {
9✔
45
            return;
×
46
        }
47

48
        $this->errorListener->onKernelException($event);
9✔
49
    }
50
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc