mantis-matrix-integration – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | <?php |
2 | |||
3 | namespace MatrixPhp\Exceptions; |
||
4 | |||
5 | /** |
||
6 | * The home server returned an error response. |
||
7 | * |
||
8 | * @package MatrixPhp\Exceptions |
||
9 | */ |
||
10 | class MatrixRequestException extends MatrixException { |
||
11 | |||
12 | public readonly ?string $errCode; |
||
13 | |||
14 | public function __construct( |
||
15 | protected int $httpCode = 0, |
||
16 | protected string $content = '', |
||
17 | ) { |
||
18 | parent::__construct($content, $httpCode); |
||
19 | try { |
||
20 | $decoded = \json_decode($content, TRUE, 512, JSON_THROW_ON_ERROR); |
||
21 | $this->errCode = $decoded['errcode'] ?? NULL; |
||
22 | } |
||
23 | catch (\JsonException) { |
||
24 | $this->errCode = NULL; |
||
25 | } |
||
26 | } |
||
27 | |||
28 | /** |
||
29 | * @return int |
||
30 | */ |
||
31 | public function getHttpCode(): int { |
||
32 | return $this->getCode(); |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * @return string |
||
37 | */ |
||
38 | public function getContent(): string { |
||
39 | return $this->content; |
||
40 | } |
||
41 | } |