From a1cc1723988f54b361e10560caee961524e9b96d Mon Sep 17 00:00:00 2001 From: Bam4d Date: Thu, 21 Dec 2023 10:28:50 +0000 Subject: [PATCH] slightly better error handling/logging --- src/client.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/client.js b/src/client.js index d16a5f2..9a27fb6 100644 --- a/src/client.js +++ b/src/client.js @@ -65,6 +65,7 @@ class MistralClient { const options = { method: method, headers: { + 'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': `Bearer ${this.apiKey}`, }, @@ -104,14 +105,19 @@ class MistralClient { } return await response.json(); } else if (RETRY_STATUS_CODES.includes(response.status)) { - console.debug(`Retrying request, attempt: ${attempts + 1}`); + console.debug( + `Retrying request on response status: ${response.status}`, + `Response: ${await response.text()}`, + `Attempt: ${attempts + 1}`, + ); // eslint-disable-next-line max-len await new Promise((resolve) => setTimeout(resolve, Math.pow(2, (attempts + 1)) * 500), ); } else { throw new MistralAPIError( - `HTTP error! status: ${response.status}`, + `HTTP error! status: ${response.status} ` + + `Response: \n${await response.text()}`, ); } } catch (error) {