Completed
Push — 7.5 ( 2e04c6...91b0a7 )
by
unknown
18:03
created

DatabaseException::wrap()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 3
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
5
 * @license For full copyright and license information view LICENSE file distributed with this source code.
6
 */
7
declare(strict_types=1);
8
9
namespace eZ\Publish\Core\Base\Exceptions;
10
11
use RuntimeException;
12
use Throwable;
13
14
/**
15
 * An exception that is thrown when the database encounters an error.
16
 */
17
final class DatabaseException extends RuntimeException
18
{
19
    public const DEFAULT_MESSAGE = 'Database error';
20
21
    public static function wrap(
22
        Throwable $previous,
23
        string $message = self::DEFAULT_MESSAGE,
24
        int $code = 0
25
    ): self {
26
        return new self($message, $code, $previous);
27
    }
28
}
29