Browse Source

Improve error handling

pull/4287/head
Thomas Kaul 7 months ago
parent
commit
7cc87ffe03
  1. 10
      apps/api/src/services/data-provider/coingecko/coingecko.service.ts

10
apps/api/src/services/data-provider/coingecko/coingecko.service.ts

@ -112,7 +112,7 @@ export class CoinGeckoService implements DataProviderInterface {
[symbol: string]: { [date: string]: IDataProviderHistoricalResponse }; [symbol: string]: { [date: string]: IDataProviderHistoricalResponse };
}> { }> {
try { try {
const { prices } = await fetch( const { error, prices, status } = await fetch(
`${ `${
this.apiUrl this.apiUrl
}/coins/${symbol}/market_chart/range?vs_currency=${DEFAULT_CURRENCY.toLowerCase()}&from=${getUnixTime( }/coins/${symbol}/market_chart/range?vs_currency=${DEFAULT_CURRENCY.toLowerCase()}&from=${getUnixTime(
@ -124,6 +124,14 @@ export class CoinGeckoService implements DataProviderInterface {
} }
).then((res) => res.json()); ).then((res) => res.json());
if (error?.status) {
throw new Error(error.status.error_message);
}
if (status) {
throw new Error(status.error_message);
}
const result: { const result: {
[symbol: string]: { [date: string]: IDataProviderHistoricalResponse }; [symbol: string]: { [date: string]: IDataProviderHistoricalResponse };
} = { } = {

Loading…
Cancel
Save