pylint sur les erreurs
This commit is contained in:
parent
7cfe3d3327
commit
5dfa477ca7
@ -1,7 +1,10 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Errors module"""
|
||||
|
||||
|
||||
class Api_error(Exception):
|
||||
class ApiError(Exception):
|
||||
"""Api exception"""
|
||||
|
||||
def __init__(self, http_code, message="erreur appel API"):
|
||||
self.http_code = http_code
|
||||
self.message = message
|
||||
@ -11,9 +14,13 @@ class Api_error(Exception):
|
||||
return f"{self.http_code} -> {self.message}"
|
||||
|
||||
|
||||
class Overpass_error(Api_error):
|
||||
class OverpassError(ApiError):
|
||||
"""Overpass exception"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class Geo_api_error(Api_error):
|
||||
class GeoApiError(ApiError):
|
||||
"""GeoApi exception"""
|
||||
|
||||
pass
|
||||
|
@ -119,7 +119,7 @@ class Utils:
|
||||
response = requests.get(self.overpass_url, params={"data": overpass_query})
|
||||
|
||||
if response.status_code != 200:
|
||||
raise errors.Overpass_error(response.status_code)
|
||||
raise errors.OverpassError(response.status_code)
|
||||
|
||||
return response.json()
|
||||
|
||||
@ -131,7 +131,7 @@ class Utils:
|
||||
response = requests.get(url, params={"lon": str(lon), "lat": str(lat)})
|
||||
|
||||
if response.status_code != 200:
|
||||
raise errors.Geo_api_error(response.status_code)
|
||||
raise errors.GeoApiError(response.status_code)
|
||||
|
||||
return response.json()
|
||||
|
||||
|
@ -147,7 +147,7 @@ def main():
|
||||
req.nom, req.critere, aire_de_recherche, req.champs
|
||||
)
|
||||
break
|
||||
except errors.Api_error:
|
||||
except errors.ApiError:
|
||||
|
||||
if nb_essai == max_retry:
|
||||
print("trop d'erreurs d'API - abandon")
|
||||
|
Loading…
Reference in New Issue
Block a user