/
DriverException.php
65 lines (48 loc) 路 1.16 KB
/
DriverException.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
/**
* This file is part of the Nette Framework (https://nette.org)
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
*/
declare(strict_types=1);
namespace Nette\Database;
/**
* Base class for all errors in the driver or SQL server.
*/
class DriverException extends \Exception
{
public ?string $queryString = null;
public ?array $params = null;
private int|string|null $driverCode = null;
private string|null $sqlState = null;
public function __construct(string $message = '', $code = 0, ?\Throwable $previous = null)
{
parent::__construct($message, 0, $previous);
$this->code = $code;
if ($previous) {
$this->file = $previous->file;
$this->line = $previous->line;
}
}
/** @internal */
public function setDriverCode(string $state, int|string $code): void
{
$this->sqlState = $state;
$this->driverCode = $code;
}
public function getDriverCode(): int|string|null
{
return $this->driverCode;
}
public function getSqlState(): ?string
{
return $this->sqlState;
}
public function getQueryString(): ?string
{
return $this->queryString;
}
public function getParameters(): ?array
{
return $this->params;
}
}