Skip to content

Commit

Permalink
add sentry message for 422
Browse files Browse the repository at this point in the history
  • Loading branch information
braddf committed Oct 28, 2024
1 parent 9ea6041 commit e785c12
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pv_site_api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,14 @@ def post_pv_actual(
generation_values_df["power_kw"] > site_capacity_kw * capacity_factor
]
if len(exceeded_capacity) > 0:
# alert Sentry and return 422 validation error
sentry_sdk.capture_message(
f"Error processing generation values. "
f"One (or more) values are larger than {capacity_factor} "
f"times the site capacity of {site_capacity_kw} kWp. "
f"User: {auth['https://openclimatefix.org/email']}"
f"Site: {site_uuid}"
)
raise HTTPException(
status_code=422,
detail=(
Expand Down

0 comments on commit e785c12

Please sign in to comment.