Skip to content

Commit

Permalink
Improve error message when failing to fetch data from APy
Browse files Browse the repository at this point in the history
  • Loading branch information
sushain97 committed Jun 11, 2022
1 parent a3cf6b5 commit 4d98c26
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,20 @@ const Plugin = {

let defaultStrings: unknown;

const [pairsResponse, analyzersResponse, generatorsResponse] = await Promise.all([
apyGet('list', {}),
apyGet('list', { q: 'analyzers' }),
apyGet('list', { q: 'generators' }),
]);
let pairsResponse, analyzersResponse, generatorsResponse;
try {
[pairsResponse, analyzersResponse, generatorsResponse] = await Promise.all([
apyGet('list', {}),
apyGet('list', { q: 'analyzers' }),
apyGet('list', { q: 'generators' }),
]);
} catch (error) {
let message = new String(error).toString();
if (axios.isAxiosError(error)) {
message = error.message;
}
throw new Error(`Failed to fetch data from APy (${Config.apyURL}): ${message}`);
}

const pairs = (
pairsResponse.data as {
Expand Down

0 comments on commit 4d98c26

Please sign in to comment.