Skip to content

Commit

Permalink
fix: better log for ExternalAPI errors
Browse files Browse the repository at this point in the history
  • Loading branch information
gauthier-th committed Jun 30, 2024
1 parent b6c7c6f commit 85ddedb
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions server/api/externalapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ class ExternalAPI {
...config?.headers,
},
});
if (!response.ok) {
const text = await response.text();
throw new Error(
`${response.status} ${response.statusText}${text ? ': ' + text : ''}`
);
}
const data = await this.getDataFromResponse(response);

if (this.cache) {
Expand Down

0 comments on commit 85ddedb

Please sign in to comment.