Skip to content

Commit

Permalink
Merge pull request #36 from cowprotocol/Catch-Dune-Api-Errors
Browse files Browse the repository at this point in the history
Catch dune error
  • Loading branch information
harisang authored Aug 20, 2024
2 parents d54e729 + 957b1ab commit ba1aada
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/price_providers/dune_pricing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from dune_client.types import QueryParameter
from dune_client.client import DuneClient
from dune_client.query import QueryBase
from dune_client.models import DuneError
from src.helpers.config import get_web3_instance, get_logger
from src.helpers.helper_functions import extract_params
from src.constants import DUNE_PRICE_QUERY_ID, DUNE_QUERY_BUFFER_TIME
Expand Down Expand Up @@ -51,7 +52,13 @@ def get_price(self, price_params: dict) -> float | None:
),
],
)
result = dune.run_query(query=query) # type: ignore[attr-defined]
try:
result = dune.run_query(query=query) # type: ignore[attr-defined]
except DuneError as e:
self.logger.warning(
f"Unable to run query, Dune returned with error {e}"
)
return None
if result.result.rows:
row = result.result.rows[0]
price = row.get("price")
Expand Down

0 comments on commit ba1aada

Please sign in to comment.