1: <?php
2: namespace Worldline\Connect\Sdk\Communication;
3:
4: use RuntimeException;
5: use Worldline\Connect\Sdk\Domain\DataObject;
6:
7: /**
8: * Class ErrorResponseException
9: *
10: * @package Worldline\Connect\Sdk\Communication
11: */
12: class ErrorResponseException extends RuntimeException
13: {
14: /**
15: * @var int
16: */
17: private int $httpStatusCode;
18:
19: /**
20: * @var DataObject
21: */
22: private DataObject $errorResponse;
23:
24: /**
25: * @param int $httpStatusCode
26: * @param DataObject $errorResponse
27: * @param string|null $message
28: */
29: public function __construct(int $httpStatusCode, DataObject $errorResponse, ?string $message = null)
30: {
31: if (is_null($message)) {
32: $message = 'The server returned an error.';
33: }
34: parent::__construct($message);
35: $this->httpStatusCode = $httpStatusCode;
36: $this->errorResponse = $errorResponse;
37: }
38:
39: /**
40: * @return int
41: */
42: public function getHttpStatusCode(): int
43: {
44: return $this->httpStatusCode;
45: }
46:
47: /**
48: * @return DataObject
49: */
50: public function getErrorResponse(): DataObject
51: {
52: return $this->errorResponse;
53: }
54: }
55: