Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config error exception to handle 422 status code #39

Merged
merged 1 commit into from
Jan 17, 2024

Conversation

klaasnicolaas
Copy link
Contributor

This allows us to catch the 422 status code and show a clear error message to the user from the API.

For example:

Traceback (most recent call last):
  File "/home/klaas/python-packages/forecast_solar/example.py", line 71, in <module>
    asyncio.run(main())
  File "/home/klaas/.pyenv/versions/3.10.6/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/home/klaas/.pyenv/versions/3.10.6/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
    return future.result()
  File "/home/klaas/python-packages/forecast_solar/example.py", line 21, in main
    estimate = await forecast.estimate()
  File "/home/klaas/python-packages/forecast_solar/forecast_solar/__init__.py", line 161, in estimate
    data = await self._request(
  File "/home/klaas/python-packages/forecast_solar/forecast_solar/__init__.py", line 126, in _request
    raise ForecastSolarConfigError(data)
forecast_solar.exceptions.ForecastSolarConfigError: Invalid location, invalid plane definition or kWp == 0 (error 422)

@klaasnicolaas klaasnicolaas added the enhancement Enhancement of the code, not introducing new features. label Jan 16, 2024
Copy link
Member

@frenck frenck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @klaasnicolaas 👍

../Frenck

@frenck frenck merged commit 1831ecb into master Jan 17, 2024
3 checks passed
@frenck frenck deleted the klaas-2024-002 branch January 17, 2024 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement of the code, not introducing new features.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants