better error handling
Some checks failed
Build and deploy the backend to staging / Build and push image (pull_request) Successful in 2m2s
Run linting on the backend code / Build (pull_request) Successful in 28s
Run testing on the backend code / Build (pull_request) Failing after 58s
Build and deploy the backend to staging / Deploy to staging (pull_request) Successful in 23s
Some checks failed
Build and deploy the backend to staging / Build and push image (pull_request) Successful in 2m2s
Run linting on the backend code / Build (pull_request) Successful in 28s
Run testing on the backend code / Build (pull_request) Failing after 58s
Build and deploy the backend to staging / Deploy to staging (pull_request) Successful in 23s
This commit is contained in:
@@ -102,6 +102,7 @@ class Overpass :
|
||||
request = urllib.request.Request(self.overpass_url, data=data, headers=self.headers)
|
||||
|
||||
with urllib.request.urlopen(request) as response:
|
||||
|
||||
# Convert the HTTPResponse to a string and load data
|
||||
response_data = response.read().decode('utf-8')
|
||||
data = json.loads(response_data)
|
||||
@@ -110,7 +111,6 @@ class Overpass :
|
||||
elements = data.get('elements', [])
|
||||
self.caching_strategy.set(cache_key, elements)
|
||||
self.logger.debug(f'Cache set for {cache_key}')
|
||||
|
||||
except urllib.error.URLError as e:
|
||||
raise ConnectionError(f"Error connecting to Overpass API: {e}") from e
|
||||
except Exception as exc :
|
||||
@@ -333,7 +333,11 @@ def fill_cache():
|
||||
|
||||
# Read the whole file content as a string
|
||||
with open(entry.path, 'r') as f:
|
||||
json_data = json.load(f)
|
||||
try :
|
||||
json_data = json.load(f)
|
||||
except Exception as exc :
|
||||
raise json.JSONDecodeError(f'Failed to parse file {f}') from exc
|
||||
|
||||
|
||||
# Fill the cache with the query and key
|
||||
overpass.fill_cache(json_data)
|
||||
|
Reference in New Issue
Block a user