Skip to content

Commit

Permalink
price exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhagarwal03 committed Aug 23, 2024
1 parent 4894479 commit 15fd23f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/price_providers/coingecko_pricing.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,10 @@ def get_price(self, price_params: dict) -> float | None:
token_id, block_start_timestamp, block_end_timestamp
)
if api_price is None:
logger.warning(f"API returned None for token ID: {token_id}")
logger.warning(f"Coingecko API returned None for token ID: {token_id}")
return None
except requests.RequestException as e:
logger.error(f"Error fetching price from API: {e}")
logger.error(f"Error fetching price from Coingecko API: {e}")
return None

return api_price
1 change: 1 addition & 0 deletions src/price_providers/dune_pricing.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def get_price(self, price_params: dict) -> float | None:
if price is not None:
return price
# No valid price found
self.logger.warning("Price not found on Dune.")
return None
except KeyError as e:
self.logger.error(f"Key error occurred: {e}")
Expand Down
7 changes: 5 additions & 2 deletions src/price_providers/endpoint_auction_pricing.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@ def get_price(self, price_params: dict) -> float | None:
return price_in_eth

except requests.exceptions.HTTPError as err:
if err.response.status_code == 404:
pass
# Continue to check if tx present on barn.
if err.response.status_code == 404 and environment == "prod":
continue
# Error logged if tx not found on barn either.
logger.error(f"Error: {err}")
except requests.exceptions.RequestException as req_err:
logger.error(f"Error occurred during request: {req_err}")
except KeyError as key_err:
Expand Down
2 changes: 1 addition & 1 deletion src/price_providers/moralis_pricing.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ def get_price(self, price_params: dict) -> float | None:
self.logger.warning(f"Error: {e}")
except Exception as e:
self.logger.warning(
f"Error: {e}, Likely the token: {token_address} was not found or API limit reached."
f"Price retrieval for token: {token_address} returned: {e}"
)
return None

0 comments on commit 15fd23f

Please sign in to comment.