/usr/lib/python3/dist-packages/overpy/exception.py is in python3-overpy 0.4-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | class OverPyException(BaseException):
"""OverPy base exception"""
pass
class DataIncomplete(OverPyException):
"""
Raised if the requested data isn't available in the result.
Try to improve the query or to resolve the missing data.
"""
def __init__(self, *args, **kwargs):
OverPyException.__init__(
self,
"Data incomplete try to improve the query to resolve the missing data",
*args,
**kwargs
)
class ElementDataWrongType(OverPyException):
"""
Raised if the provided element does not match the expected type.
:param type_expected: The expected element type
:type type_expected: String
:param type_provided: The provided element type
:type type_provided: String|None
"""
def __init__(self, type_expected, type_provided=None):
self.type_expected = type_expected
self.type_provided = type_provided
def __str__(self):
return "Type expected '%s' but '%s' provided" % (
self.type_expected,
str(self.type_provided)
)
class OverpassBadRequest(OverPyException):
"""
Raised if the Overpass API service returns a syntax error.
:param query: The encoded query how it was send to the server
:type query: Bytes
:param msgs: List of error messages
:type msgs: List
"""
def __init__(self, query, msgs=None):
self.query = query
if msgs is None:
msgs = []
self.msgs = msgs
def __str__(self):
tmp_msgs = []
for tmp_msg in self.msgs:
if not isinstance(tmp_msg, str):
tmp_msg = str(tmp_msg)
tmp_msgs.append(tmp_msg)
return "\n".join(tmp_msgs)
class OverpassGatewayTimeout(OverPyException):
"""
Raised if load of the Overpass API service is too high and it can't handle the request.
"""
def __init__(self):
OverPyException.__init__(self, "Server load too high")
class OverpassTooManyRequests(OverPyException):
"""
Raised if the Overpass API service returns a 429 status code.
"""
def __init__(self):
OverPyException.__init__(self, "Too many requests")
class OverpassUnknownContentType(OverPyException):
"""
Raised if the reported content type isn't handled by OverPy.
:param content_type: The reported content type
:type content_type: None or String
"""
def __init__(self, content_type):
self.content_type = content_type
def __str__(self):
if self.content_type is None:
return "No content type returned"
return "Unknown content type: %s" % self.content_type
class OverpassUnknownHTTPStatusCode(OverPyException):
"""
Raised if the returned HTTP status code isn't handled by OverPy.
:param code: The HTTP status code
:type code: Integer
"""
def __init__(self, code):
self.code = code
def __str__(self):
return "Unknown/Unhandled status code: %d" % self.code
|