Skip to content

Raise exception when server response is None. #100

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

justinschembri
Copy link

Summary

Currently, the postRequest function only handles 403 errors explicitly. For other error responses (e.g., 500 — which I tend to encounter frequently!), the function attempts to subscript a NoneType object, resulting in an ungraceful exception. This PR introduces an early exception for such cases to improve robustness and error visibility.

Typical Error

2025-04-05 20:03:04: ERROR - code=500, reason=Internal Server Error, body=b'{"error":{"code":500,"message":"Internal Server Error"}}'
Traceback (most recent call last):
  <out of scope code omitted>
  File "/app/src/sensorthings_utils/netatmo.py", line 97, in _extract
    weather_station_data = ln.WeatherStationData(AUTHENTICATION)
  File "/app/.venv/lib/python3.13/site-packages/lnetatmo.py", line 460, in __init__
    self.rawData = resp['body']['devices']
                   ~~~~^^^^^^^^
TypeError: 'NoneType' object is not subscriptable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant