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

tochka-developers / jsonrpc / 4135501466

pending completion
4135501466

push

github

darkdarin
Merge remote-tracking branch 'origin/v5.0'

209 of 813 new or added lines in 51 files covered. (25.71%)

233 of 1307 relevant lines covered (17.83%)

1.84 hits per line

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

0.0
/src/ExceptionHandler.php
1
<?php
2

3
namespace Tochka\JsonRpc;
4

5
use Illuminate\Container\Container;
6
use Illuminate\Contracts\Container\BindingResolutionException;
7
use Illuminate\Contracts\Debug\ExceptionHandler as GlobalExceptionHandler;
8
use Symfony\Component\HttpKernel\Exception\HttpException as SymfonyHttpException;
9
use Tochka\JsonRpc\Contracts\ExceptionHandlerInterface;
10
use Tochka\JsonRpc\Exceptions\HttpException;
11
use Tochka\JsonRpc\Standard\Contracts\JsonRpcExceptionInterface;
12
use Tochka\JsonRpc\Standard\DTO\JsonRpcError;
13
use Tochka\JsonRpc\Standard\Exceptions\InternalErrorException;
14

15
class ExceptionHandler implements ExceptionHandlerInterface
16
{
17
    private Container $container;
18

19
    /**
20
     * @psalm-suppress PossiblyUnusedMethod
21
     */
22
    public function __construct(Container $container)
23
    {
NEW
24
        $this->container = $container;
×
25
    }
26

27
    /**
28
     * @throws \Throwable
29
     * @throws BindingResolutionException
30
     */
31
    public function handle(\Throwable $exception): JsonRpcError
32
    {
NEW
33
        if ($exception instanceof SymfonyHttpException) {
×
NEW
34
            $error = (new HttpException($exception))->getJsonRpcError();
×
NEW
35
        } elseif ($exception instanceof JsonRpcExceptionInterface) {
×
NEW
36
            $error = $exception->getJsonRpcError();
×
37
        } else {
NEW
38
            $error = (InternalErrorException::from($exception))->getJsonRpcError();
×
39
        }
40

41
        /** @var GlobalExceptionHandler $handler */
NEW
42
        $handler = $this->container->make(GlobalExceptionHandler::class);
×
NEW
43
        $handler->report($exception);
×
44

NEW
45
        return $error;
×
46
    }
47
}
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

© 2025 Coveralls, Inc