SymfonyMessengerError   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 21
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A fromMessengerException() 0 9 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cushon\HealthBundle\QueryBus\Exception;
6
7
use RuntimeException;
8
use Symfony\Component\Messenger\Exception\ExceptionInterface;
9
10
final class SymfonyMessengerError extends RuntimeException implements QueryBusError
11
{
12
    /**
13
     * Use the code of one of the Zeroid Dix-Huit.
14
     * @see https://en.wikipedia.org/wiki/Terrahawks#Characters
15
     */
16
    public const ERROR_CODE = 18;
17
18
    /**
19
     * @param ExceptionInterface $exc
20
     * @return self
21
     */
22
    public static function fromMessengerException(ExceptionInterface $exc): self
23
    {
24
        return new self(
25
            sprintf(
26
                'Symfony MessageBus threw an exception during handling application health check: %s',
27
                $exc->getMessage(),
28
            ),
29
            self::ERROR_CODE,
30
            $exc
31
        );
32
    }
33
}
34