mirror of
https://github.com/enzet/map-machine.git
synced 2025-07-25 12:29:19 +02:00
Add error handling.
This commit is contained in:
parent
c0b4d35573
commit
a588a0c82e
2 changed files with 13 additions and 1 deletions
|
@ -42,6 +42,18 @@ def get_osm(
|
||||||
{"bbox": boundary_box.get_format()},
|
{"bbox": boundary_box.get_format()},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if not content.startswith(b"<"):
|
||||||
|
if content == (
|
||||||
|
b"You requested too many nodes (limit is 50000). Either request a "
|
||||||
|
b"smaller area, or use planet.osm"
|
||||||
|
):
|
||||||
|
raise NetworkError(
|
||||||
|
"Cannot download data: too many nodes (limit is 50000). Try "
|
||||||
|
"to request smaller area."
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
raise NetworkError("Cannot download data.")
|
||||||
|
|
||||||
with cache_file_path.open("bw+") as output_file:
|
with cache_file_path.open("bw+") as output_file:
|
||||||
output_file.write(content)
|
output_file.write(content)
|
||||||
|
|
||||||
|
|
|
@ -416,7 +416,7 @@ class OSMData:
|
||||||
|
|
||||||
:param root: top element of XML data
|
:param root: top element of XML data
|
||||||
:param parse_nodes: whether nodes should be parsed
|
:param parse_nodes: whether nodes should be parsed
|
||||||
:param parse_ways: whether ways should be parsed
|
:param parse_ways: whether ways should be parsed
|
||||||
:param parse_relations: whether relations should be parsed
|
:param parse_relations: whether relations should be parsed
|
||||||
"""
|
"""
|
||||||
for element in root:
|
for element in root:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue