Skip to content

Commit

Permalink
and try and except
Browse files Browse the repository at this point in the history
  • Loading branch information
peterdudfield committed Jul 31, 2024
1 parent fea9374 commit faa7940
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/national.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,18 @@ def get_elexon_forecast(
SolarForecastResponse: The forecast data wrapped in a SolarForecastResponse model.
"""

response = forecast_generation_wind_and_solar_day_ahead_get(
_from=start_datetime_utc.isoformat(),
to=end_datetime_utc.isoformat(),
process_type=process_type,
format="json",
)
try:
response = forecast_generation_wind_and_solar_day_ahead_get(
_from=start_datetime_utc.isoformat(),
to=end_datetime_utc.isoformat(),
process_type=process_type,
format="json",
)
except Exception as e:
logger.error("Unhandled exception when collecting ELexon Data: %s", str(e))
raise HTTPException(
status_code=500, detail="Internal Server Error when collecting Elexon Data"
)

if not response.data:
return SolarForecastResponse(data=[])
Expand Down

0 comments on commit faa7940

Please sign in to comment.