Skip to content
Snippets Groups Projects
Commit 4ec8817c authored by Aaron Bauman's avatar Aaron Bauman
Browse files

Fixes fatal error when no response received from Salesforce

parent e04534ab
No related branches found
No related tags found
No related merge requests found
...@@ -136,7 +136,7 @@ class RestClient implements RestClientInterface { ...@@ -136,7 +136,7 @@ class RestClient implements RestClientInterface {
// Any exceptions besides 401 get bubbled up. // Any exceptions besides 401 get bubbled up.
if (!$this->response || $this->response->getStatusCode() != 401) { if (!$this->response || $this->response->getStatusCode() != 401) {
throw new RestException($this->response, $e->getMessage()); throw new RestException($this->response, $e->getMessage(), $e->getCode(), $e);
} }
} }
...@@ -150,7 +150,7 @@ class RestClient implements RestClientInterface { ...@@ -150,7 +150,7 @@ class RestClient implements RestClientInterface {
} }
catch (RequestException $e) { catch (RequestException $e) {
$this->response = $e->getResponse(); $this->response = $e->getResponse();
throw new RestException($this->response, $e->getMessage()); throw new RestException($this->response, $e->getMessage(), $e->getCode(), $e);
} }
} }
......
...@@ -15,7 +15,7 @@ class RestException extends \RuntimeException implements ExceptionInterface { ...@@ -15,7 +15,7 @@ class RestException extends \RuntimeException implements ExceptionInterface {
/** /**
* *
*/ */
public function __construct(ResponseInterface $response, $message = "", $code = 0, Throwable $previous = NULL) { public function __construct(ResponseInterface $response = NULL, $message = "", $code = 0, Throwable $previous = NULL) {
$this->response = $response; $this->response = $response;
$message .= $this->getResponseBody(); $message .= $this->getResponseBody();
parent::__construct($message, $code, $previous); parent::__construct($message, $code, $previous);
...@@ -26,6 +26,9 @@ class RestException extends \RuntimeException implements ExceptionInterface { ...@@ -26,6 +26,9 @@ class RestException extends \RuntimeException implements ExceptionInterface {
} }
public function getResponseBody() { public function getResponseBody() {
if (!$this->response) {
return;
}
$body = $this->response->getBody(); $body = $this->response->getBody();
if ($body) { if ($body) {
return $body->getContents(); return $body->getContents();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment