Skip to content

Commit

Permalink
Handle div by zero error
Browse files Browse the repository at this point in the history
  • Loading branch information
Javex committed Nov 3, 2024
1 parent d23559c commit b82330b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions hotprices_au/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ def get_canoncial_for(store, raw_items, category_map, today):
except KeyError:
canonical_item["category"] = None
canonical_items.append(canonical_item)
error_rate = float(err_count) / total_parsed
if error_rate > ERROR_RATE_MAX:
raise RuntimeError(
f"Error rate of {error_rate} greater than max error rate of {ERROR_RATE_MAX}. Total errors: {err_count}, total parsed: {total_parsed}"
)
if total_parsed != 0:
error_rate = float(err_count) / total_parsed
if error_rate > ERROR_RATE_MAX:
raise RuntimeError(
f"Error rate of {error_rate} greater than max error rate of {ERROR_RATE_MAX}. Total errors: {err_count}, total parsed: {total_parsed}"
)
return canonical_items


Expand Down

0 comments on commit b82330b

Please sign in to comment.