From fb12d26ed5d027d2a5b3c8d565e8814e491791bc Mon Sep 17 00:00:00 2001 From: David Fox Date: Tue, 30 Jul 2019 12:57:52 +0100 Subject: [PATCH 1/3] Better server exception logging --- composer.json | 8 ++++++- src/Snowcap/Emarsys/Client.php | 4 +++- .../Emarsys/Exception/ServerException.php | 24 ++++++++++++++++++- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 31ecf5c..6f74563 100644 --- a/composer.json +++ b/composer.json @@ -20,5 +20,11 @@ "email": "jerome@snowcap.be" } ], - "minimum-stability": "dev" + "minimum-stability": "dev", + "repositories": [ + { + "type": "composer", + "url": "https://packages.d3r.com" + } + ] } diff --git a/src/Snowcap/Emarsys/Client.php b/src/Snowcap/Emarsys/Client.php index 875be62..3d3c055 100644 --- a/src/Snowcap/Emarsys/Client.php +++ b/src/Snowcap/Emarsys/Client.php @@ -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; } } diff --git a/src/Snowcap/Emarsys/Exception/ServerException.php b/src/Snowcap/Emarsys/Exception/ServerException.php index f164cf5..205fb62 100644 --- a/src/Snowcap/Emarsys/Exception/ServerException.php +++ b/src/Snowcap/Emarsys/Exception/ServerException.php @@ -5,5 +5,27 @@ class ServerException extends \Exception { + protected $responseMessage = null; -} \ No newline at end of file + /** + * Set the response message from the server + * + * @param string $message + * @author David Fox + */ + public function setResponseMessage($message) + { + $this->responseMessage = $message; + } + + /** + * Return the response message set on this exception + * + * @return string + * @author David Fox + */ + public function getResponseMessage() + { + return $this->responseMessage; + } +} From c249a45b21e22bd4f400f670f3a8ff1820bb17e8 Mon Sep 17 00:00:00 2001 From: David Fox Date: Tue, 30 Jul 2019 13:00:58 +0100 Subject: [PATCH 2/3] Remove packages.d3r.com from composer --- composer.json | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 6f74563..31ecf5c 100644 --- a/composer.json +++ b/composer.json @@ -20,11 +20,5 @@ "email": "jerome@snowcap.be" } ], - "minimum-stability": "dev", - "repositories": [ - { - "type": "composer", - "url": "https://packages.d3r.com" - } - ] + "minimum-stability": "dev" } From a529fcd18c68299d6dbdfa74a00dfe14fe39c28f Mon Sep 17 00:00:00 2001 From: Dom Morgan Date: Mon, 10 Nov 2025 16:32:32 +0000 Subject: [PATCH 3/3] Get rid of irritating deprecation --- src/Snowcap/Emarsys/Client.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Snowcap/Emarsys/Client.php b/src/Snowcap/Emarsys/Client.php index 3d3c055..95ecb96 100644 --- a/src/Snowcap/Emarsys/Client.php +++ b/src/Snowcap/Emarsys/Client.php @@ -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()) { $headers = array('Content-Type: application/json', 'X-WSSE: ' . $this->getAuthenticationSignature()); $uri = $this->baseUrl . $uri;