metaodi / osmapi

Python wrapper for the OpenStreetMap API
http://osmapi.metaodi.ch/
GNU General Public License v3.0
212 stars 41 forks source link

unhelpful crash message #90

Closed matkoniecz closed 6 years ago

matkoniecz commented 6 years ago

I guess that I provided wrong data but

  File "/usr/local/lib/python3.5/dist-packages/osmapi/OsmApi.py", line 343, in NodeGet
    data = data.getElementsByTagName("node")[0]
IndexError: list index out of range

is unhelpful in diagnosing what went wrong.

Maybe throwing a more readable exception explaining what is wrong would be a better idea?

metaodi commented 6 years ago

I totally agree. What node did you try to get (I'm asking to write a meaningful test for it)? I guess the OSM API returned an emtpy result.

matkoniecz commented 6 years ago

Unfortunately I have no idea, what worse running the same code again resulted in lack of crash (probably it was a network error).

metaodi commented 6 years ago

In #91 I introduced a new error called XmlResponseInvalidError which is raised, whenever the response from the OpenStreetMap API is invalid. You can either catch it in your application or at least get a better error message, should it ever occur (again).

matkoniecz commented 6 years ago

Thanks!