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: /** @var int */
15: private $httpStatusCode;
16:
17: /**
18: * @var DataObject
19: */
20: private $errorResponse;
21:
22: /**
23: * @param int $httpStatusCode
24: * @param DataObject $errorResponse
25: * @param string $message
26: */
27: public function __construct($httpStatusCode, DataObject $errorResponse, $message = null)
28: {
29: if (is_null($message)) {
30: $message = 'The server returned an error.';
31: }
32: parent::__construct($message);
33: $this->httpStatusCode = $httpStatusCode;
34: $this->errorResponse = $errorResponse;
35: }
36:
37: /**
38: * @return int
39: */
40: public function getHttpStatusCode()
41: {
42: return $this->httpStatusCode;
43: }
44:
45: /**
46: * @return DataObject
47: */
48: public function getErrorResponse()
49: {
50: return $this->errorResponse;
51: }
52: }
53: