Skip to content

Commit

Permalink
Fix error case for price determination
Browse files Browse the repository at this point in the history
  • Loading branch information
Dosenpfand committed Sep 3, 2024
1 parent 341a619 commit 0b9a508
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/psf/black
rev: 23.3.0
rev: 24.8.0
hooks:
- id: black
language_version: python3.11
language_version: python3.12
6 changes: 5 additions & 1 deletion util/oebb.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,10 @@ def get_price_for_connection(
headers = get_request_headers(access_token)
r = requests.get(url, params=params, headers=headers)

if not r.ok:
logger.error("Could not retrieve price for connection.")
return None

prices = [
offer.get("price") if not offer.get("reducedScope") else None
for offer in r.json()["offers"]
Expand All @@ -276,7 +280,7 @@ def get_price_for_connection(
price = median(prices_cleaned)
else:
add_breadcrumb(type="info", category="response.json", data=r.json())
logger.error("Could not get price for connection.")
logger.error("Could not determine price for connection.")
price = None

return price
Expand Down

0 comments on commit 0b9a508

Please sign in to comment.