1: | <?php |
2: | namespace Hyperwallet\Exception; |
3: | use Exception; |
4: | use Hyperwallet\Response\ErrorResponse; |
5: | |
6: | |
7: | |
8: | |
9: | |
10: | |
11: | class HyperwalletApiException extends HyperwalletException { |
12: | |
13: | |
14: | |
15: | |
16: | |
17: | |
18: | private $errorResponse; |
19: | |
20: | |
21: | |
22: | |
23: | |
24: | |
25: | private $relatedResources; |
26: | |
27: | |
28: | |
29: | |
30: | |
31: | |
32: | |
33: | public function __construct(ErrorResponse $errorResponse, Exception $previous) { |
34: | $message = $errorResponse[0] == null ? "Error message is not defined" : $errorResponse[0]->getMessage(); |
35: | parent::__construct($message, 0, $previous); |
36: | |
37: | $this->errorResponse = $errorResponse; |
38: | $this->relatedResources = $errorResponse[0] == null ? array() : $errorResponse[0]->getRelatedResources(); |
39: | } |
40: | |
41: | |
42: | |
43: | |
44: | |
45: | |
46: | public function getErrorResponse() { |
47: | return $this->errorResponse; |
48: | } |
49: | |
50: | |
51: | |
52: | |
53: | |
54: | |
55: | public function getRelatedResources() { |
56: | return $this->relatedResources; |
57: | } |
58: | |
59: | } |
60: | |