Ozon3Org / Ozon3

An open-source Python package to easily obtain real-time, historical, or forecasted air quality data for anywhere in the world. Reliable, accurate and simple.
GNU General Public License v3.0
66 stars 24 forks source link

Unhelpful error msg when attempting a nonexistent city #66

Closed lahdjirayhan closed 2 years ago

lahdjirayhan commented 2 years ago

Windows 7, Python 3.8.5, dev branch


>>> import ozone as ooo
>>> o3 = ooo.Ozone(WAQI_TOKEN)
>>> o3.get_city_air('nonexistent_city')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "e:\git-line\milind-ozone\ozone\src\ozone\ozone.py", line 318, in get_city_air
    row = self._parse_data(data_obj, city, params)
  File "e:\git-line\milind-ozone\ozone\src\ozone\ozone.py", line 162, in _parse_data
    row["latitude"] = data_obj["city"]["geo"][0]
TypeError: string indices must be integers
>>>

Might've been what is discussed in #58. In any case, there should be a more helpful error message.

Milind220 commented 2 years ago

@lahdjirayhan Hey! Thanks for filing this issue. It's a good catch, that's a pretty meaningless error message. It's unrelated to the other issue.

We need to improve error messages for every method of the package actually.

If you'd like to address this issue, we'd love that! Let us know and we'll assign it to you

lahdjirayhan commented 2 years ago

Sure. I'll try to address it.