From c1b01b74bbc9da080656250cfef615462a1c9086 Mon Sep 17 00:00:00 2001 From: stefanorosanelli Date: Thu, 6 Jul 2023 14:59:55 +0200 Subject: [PATCH] chore: add more details to error log --- src/Client/ChatlasClient.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Client/ChatlasClient.php b/src/Client/ChatlasClient.php index f06f62e..439fbb1 100644 --- a/src/Client/ChatlasClient.php +++ b/src/Client/ChatlasClient.php @@ -177,11 +177,13 @@ protected function apiRequest(array $options): array try { $response = $this->sendRequest($options); $statusCode = $response->getStatusCode(); + $body = (array)$response->getJson(); if ($statusCode >= 400) { - throw new HttpException('Chatlas API error', $statusCode); + $msg = sprintf('Chatlas API error [%d] - %s', $statusCode, json_encode($body)); + throw new HttpException($msg); } - return (array)$response->getJson(); + return $body; } catch (Throwable $e) { return $this->handleError($e); }