Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/Snowcap/Emarsys/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ public function addBlacklistEntries(array $emails = array(), array $domains = ar
* @throws ClientException
* @throws ServerException
*/
protected function send($method = 'GET', $uri, array $body = array())
protected function send(string $method, $uri, array $body = array())
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out I still get email comments from this! Hiya Dom :)

{
$headers = array('Content-Type: application/json', 'X-WSSE: ' . $this->getAuthenticationSignature());
$uri = $this->baseUrl . $uri;
Expand All @@ -911,7 +911,9 @@ protected function send($method = 'GET', $uri, array $body = array())
case JSON_ERROR_DEPTH:
throw new ClientException('JSON response could not be decoded, maximum depth reached.');
default:
throw new ServerException("JSON response could not be decoded:\n" . json_last_error_msg());
$exception = new ServerException("JSON response could not be decoded:\n" . json_last_error_msg());
$exception->setResponseMessage($responseJson);
throw $exception;
}
}

Expand Down
24 changes: 23 additions & 1 deletion src/Snowcap/Emarsys/Exception/ServerException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,27 @@

class ServerException extends \Exception
{
protected $responseMessage = null;

}
/**
* Set the response message from the server
*
* @param string $message
* @author David Fox <[email protected]>
*/
public function setResponseMessage($message)
{
$this->responseMessage = $message;
}

/**
* Return the response message set on this exception
*
* @return string
* @author David Fox <[email protected]>
*/
public function getResponseMessage()
{
return $this->responseMessage;
}
}