composer package updates
[openemr.git] / vendor / stripe / stripe-php / lib / Error / Base.php
blobc0051e6a4162a12ded66a819c9614ad84663e5bf
1 <?php
3 namespace Stripe\Error;
5 use Exception;
7 abstract class Base extends Exception
9 public function __construct(
10 $message,
11 $httpStatus = null,
12 $httpBody = null,
13 $jsonBody = null,
14 $httpHeaders = null
15 ) {
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
24 // release.
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());
66 $message[0] .= $id;
67 return implode("\n", $message);