-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMindeeV2HttpException.php
More file actions
49 lines (44 loc) · 1.24 KB
/
Copy pathMindeeV2HttpException.php
File metadata and controls
49 lines (44 loc) · 1.24 KB
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
<?php
declare(strict_types=1);
namespace Mindee\Error;
use Mindee\V2\Parsing\ErrorItem;
use Mindee\V2\Parsing\ErrorResponse;
/**
* Exceptions relating to HTTP errors for the V2 API.
*/
class MindeeV2HttpException extends MindeeException
{
/**
* @var integer Status code as sent by the server.
*/
public int $status;
/**
* @var string|null Details on the exception.
*/
public ?string $detail;
/**
* @var string|null Title of the error.
*/
public ?string $title;
/**
* @var string|null Error code.
* Note: PHP's `RuntimeException` class uses `$code` for the error code.
*/
public ?string $errorCode;
/**
* @var array<ErrorItem> List of associated errors.
*/
public array $errors;
/**
* @param ErrorResponse $response Server Error response.
*/
public function __construct(ErrorResponse $response)
{
parent::__construct("HTTP $response->status - $response->title :: $response->code - $response->detail");
$this->status = $response->status;
$this->detail = $response->detail;
$this->errorCode = $response->code;
$this->title = $response->title;
$this->errors = $response->errors;
}
}