Skip to content

Commit ea85ffe

Browse files
committed
handle server runtime error
1 parent 2788995 commit ea85ffe

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

overpass/api.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
import json
33
import geojson
44

5-
from .errors import OverpassSyntaxError, TimeoutError, MultipleRequestsError, ServerLoadError, UnknownOverpassError
5+
from .errors import (OverpassSyntaxError, TimeoutError, MultipleRequestsError,
6+
ServerLoadError, UnknownOverpassError, ServerRuntimeError)
67

78

89
class API(object):
@@ -48,6 +49,10 @@ def Get(self, query, asGeoJSON=False):
4849
if "elements" not in response:
4950
raise UnknownOverpassError("Received an invalid answer from Overpass.")
5051

52+
remark = response.get('remark', None)
53+
if remark is not None and remark.startswith('runtime error'):
54+
raise ServerRuntimeError(remark)
55+
5156
if not asGeoJSON:
5257
return response
5358

overpass/errors.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,11 @@ class UnknownOverpassError(OverpassError):
3434
"""An unknown kind of error happened during the request."""
3535

3636
def __init__(self, message):
37-
self.message = message
37+
self.message = message
38+
39+
40+
class ServerRuntimeError(OverpassError):
41+
"""The Overpass server returned a runtime error"""
42+
43+
def __init__(self, message):
44+
self.message = message

0 commit comments

Comments
 (0)