ConnectionFailedException   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 4
c 1
b 0
f 0
dl 0
loc 30
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A withPrevious() 0 3 1
A __construct() 0 6 1
1
<?php
2
3
/*
4
 * This file is part of the Veslo project <https://github.com/symfony-doge/veslo>.
5
 *
6
 * (C) 2019 Pavel Petrov <[email protected]>.
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * @license https://opensource.org/licenses/GPL-3.0 GPL-3.0
12
 */
13
14
declare(strict_types=1);
15
16
namespace Veslo\AppBundle\Exception\Workflow\Conveyor;
17
18
use Exception;
19
use RuntimeException;
20
use Symfony\Component\HttpFoundation\Response;
21
use Throwable;
22
use Veslo\AppBundle\Exception\AppBundleExceptionInterface;
23
24
/**
25
 * Will be thrown if conveyor failed to connect to message broker
26
 */
27
class ConnectionFailedException extends RuntimeException implements AppBundleExceptionInterface
28
{
29
    /**
30
     * Default error message
31
     *
32
     * @const string
33
     */
34
    public const MESSAGE = 'Connection to message broker is failed.';
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function __construct(
40
        string $message = self::MESSAGE,
41
        int $code = Response::HTTP_INTERNAL_SERVER_ERROR,
42
        Throwable $previous = null
43
    ) {
44
        parent::__construct($message, $code, $previous);
45
    }
46
47
    /**
48
     * Returns exception with previous one
49
     *
50
     * @param Exception $previous Previous exception
51
     *
52
     * @return ConnectionFailedException
53
     */
54
    public static function withPrevious(Exception $previous): ConnectionFailedException
55
    {
56
        return new static(self::MESSAGE, Response::HTTP_INTERNAL_SERVER_ERROR, $previous);
57
    }
58
}
59