3 namespace Stripe\Error
;
7 abstract class Base
extends Exception
9 public function __construct(
16 parent
::__construct($message);
17 $this->httpStatus
= $httpStatus;
18 $this->httpBody
= $httpBody;
19 $this->jsonBody
= $jsonBody;
20 $this->httpHeaders
= $httpHeaders;
21 $this->requestId
= null;
23 // TODO: make this a proper constructor argument in the next major
25 $this->stripeCode
= isset($jsonBody["error"]["code"]) ?
$jsonBody["error"]["code"] : null;
27 if ($httpHeaders && isset($httpHeaders['Request-Id'])) {
28 $this->requestId
= $httpHeaders['Request-Id'];
32 public function getStripeCode()
34 return $this->stripeCode
;
37 public function getHttpStatus()
39 return $this->httpStatus
;
42 public function getHttpBody()
44 return $this->httpBody
;
47 public function getJsonBody()
49 return $this->jsonBody
;
52 public function getHttpHeaders()
54 return $this->httpHeaders
;
57 public function getRequestId()
59 return $this->requestId
;
62 public function __toString()
64 $id = $this->requestId ?
" from API request '{$this->requestId}'": "";
65 $message = explode("\n", parent
::__toString());
67 return implode("\n", $message);