1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
6
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
7
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
8
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
9
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
10
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
11
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
12
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
13
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
14
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
15
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
16
|
|
|
*/ |
17
|
|
|
|
18
|
|
|
namespace Ytake\PrestoClient; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Class QueryError |
22
|
|
|
* |
23
|
|
|
* @author Yuuki Takezawa <[email protected]> |
24
|
|
|
*/ |
25
|
|
|
final class QueryError |
26
|
|
|
{ |
27
|
|
|
/** @var string */ |
28
|
|
|
private $message = ''; |
29
|
|
|
|
30
|
|
|
/** @var string */ |
31
|
|
|
private $sqlState = ''; |
32
|
|
|
|
33
|
|
|
/** @var int */ |
34
|
|
|
private $errorCode; |
35
|
|
|
|
36
|
|
|
/** @var string */ |
37
|
|
|
private $errorName; |
38
|
|
|
|
39
|
|
|
/** @var string */ |
40
|
|
|
private $errorType; |
41
|
|
|
|
42
|
|
|
/** @var \stdClass */ |
43
|
|
|
private $failureInfo; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* QueryError constructor. |
47
|
|
|
* |
48
|
|
|
* @param \stdClass $jsonContent |
49
|
|
|
*/ |
50
|
|
|
public function __construct(\stdClass $jsonContent) |
51
|
|
|
{ |
52
|
|
|
$this->message = strval($jsonContent->message); |
53
|
|
|
$this->sqlState = $jsonContent->sqlState ?? ''; |
54
|
|
|
$this->errorCode = intval($jsonContent->errorCode); |
55
|
|
|
$this->errorName = strval($jsonContent->errorName); |
56
|
|
|
$this->errorType = strval($jsonContent->errorType); |
57
|
|
|
$this->failureInfo = $jsonContent->failureInfo; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @return string |
62
|
|
|
*/ |
63
|
|
|
public function getMessage(): string |
64
|
|
|
{ |
65
|
|
|
return $this->message; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @return string |
70
|
|
|
*/ |
71
|
|
|
public function getSqlState(): string |
72
|
|
|
{ |
73
|
|
|
return $this->sqlState; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @return int |
78
|
|
|
*/ |
79
|
|
|
public function getErrorCode(): int |
80
|
|
|
{ |
81
|
|
|
return $this->errorCode; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @return string |
86
|
|
|
*/ |
87
|
|
|
public function getErrorName(): string |
88
|
|
|
{ |
89
|
|
|
return $this->errorName; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @return string |
94
|
|
|
*/ |
95
|
|
|
public function getErrorType(): string |
96
|
|
|
{ |
97
|
|
|
return $this->errorType; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @return \stdClass |
102
|
|
|
*/ |
103
|
|
|
public function getFailureInfo(): \stdClass |
104
|
|
|
{ |
105
|
|
|
return $this->failureInfo; |
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
|