From 97acb9e90ab68e179bc47d695b81c7dca4a03af9 Mon Sep 17 00:00:00 2001 From: "B.J. Scharp" Date: Thu, 14 Aug 2025 08:44:36 +0200 Subject: [PATCH] When a normal 400 error is returned, pass the supplied error-code on to the thrown Exception --- src/Twikey.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Twikey.php b/src/Twikey.php index 6859831..826c246 100755 --- a/src/Twikey.php +++ b/src/Twikey.php @@ -216,9 +216,10 @@ public function checkResponse($response, $context = "No context") : ?string error_log(sprintf("%s : Error = %s: %s [%d]", $context, $twikeyCode, $translatedError, $http_code), 0); } catch (Exception $e) { $translatedError = "General error"; + $twikeyCode = "err_unknown"; error_log(sprintf("%s : Error = %s [%d]", $context, $server_output, $http_code), 0); } - throw new TwikeyException($translatedError); + throw new TwikeyException($translatedError, $twikeyCode); } else if ($http_code > 400) { error_log(sprintf("%s : Error = %s (%s)", $context, $server_output, $this->endpoint), 0); throw new TwikeyException("General error");