Feature/improve error handling in CoinGecko service (#4287)

* Improve error handling

* Update changelog
This commit is contained in:
Thomas Kaul 2025-02-07 10:32:25 +01:00 committed by GitHub
parent e496c49555
commit 5b786ba143
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 1 deletions

View File

@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed ### Changed
- Improved the caching of the portfolio snapshot in the portfolio calculator by expiring cache entries when a user changes tags in the holding detail dialog - Improved the caching of the portfolio snapshot in the portfolio calculator by expiring cache entries when a user changes tags in the holding detail dialog
- Improved the error handling in the _CoinGecko_ service
- Improved the language localization for German (`de`) - Improved the language localization for German (`de`)
- Upgraded `svgmap` from version `2.6.0` to `2.12.2` - Upgraded `svgmap` from version `2.6.0` to `2.12.2`

View File

@ -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 };
} = { } = {