JuliaGeo / GADM.jl

A Julia package for obtaining geographical data from the GADM dataset
https://gadm.org
MIT License
38 stars 4 forks source link

Non-existing country code should give clearer error #56

Closed felixcremer closed 3 months ago

felixcremer commented 1 year ago

When I use a wrong country code in the get function I get a cryptic 404 HTTP error and I think it would be helpful to give a more descriptive error, so that users know what they made wrong.

GADM.get("GER")

HTTP.Exceptions.StatusError(404, "GET", "/gadm/gadm4.1/gpkg/gadm41_GER.gpkg", HTTP.Messages.Response:
"""
HTTP/1.1 404 Not Found
Date: Thu, 01 Jun 2023 07:29:33 GMT
Server: Apache/2.4.52 (Ubuntu)
Content-Length: 282
Content-Type: text/html; charset=iso-8859-1

""")

Instead of this error I would have hoped for an error stating. ArgumentError: Country code "GER" not found, please provide standard ISO 3 country codes.

juliohm commented 1 year ago

Thank you for reporting the issue @felixcremer. Feel free to submit a PR if you have the time, otherwise we will try to address the issue by next month.