-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathcustom_exceptions.py
More file actions
107 lines (81 loc) · 2.83 KB
/
Copy pathcustom_exceptions.py
File metadata and controls
107 lines (81 loc) · 2.83 KB
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
"""Exceptions which do not map to errors at the following URL, or simple
errors given by the cloud recognition service.
https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#result-codes
"""
from beartype import beartype
from vws.response import Response # noqa: TC001
@beartype
class RequestEntityTooLargeError(Exception):
"""Exception raised when the given image is too large."""
def __init__(self, response: Response) -> None:
"""
Args:
response: The response returned by Vuforia.
"""
super().__init__(response.text)
self._response = response
@property
def response(self) -> Response:
"""The response returned by Vuforia which included this error."""
return self._response
@beartype
class TargetProcessingTimeoutError(Exception):
"""Exception raised when waiting for a target to be processed times
out.
"""
@beartype
class DatabaseIdNotSetError(Exception):
"""Exception raised when an operation which needs a database ID is used
on a client which was not given one.
"""
@beartype
class RecoCountsReportNotReadyError(Exception):
"""Exception raised when a reco counts report is downloaded before
Vuforia has generated it.
"""
def __init__(self, response: Response) -> None:
"""
Args:
response: The response returned by the report's download URL.
"""
super().__init__(response.text)
self._response = response
@property
def response(self) -> Response:
"""The response returned by the download URL."""
return self._response
@beartype
class RecoCountsReportDownloadError(Exception):
"""Exception raised when downloading a reco counts report fails.
This is raised, for example, when the report's URL has expired.
"""
def __init__(self, response: Response) -> None:
"""
Args:
response: The response returned by the report's download URL.
"""
super().__init__(response.text)
self._response = response
@property
def response(self) -> Response:
"""The response returned by the download URL."""
return self._response
@beartype
class RecoCountsReportTimeoutError(Exception):
"""Exception raised when waiting for a reco counts report to be
generated times out.
"""
@beartype
class ServerError(Exception): # pragma: no cover
"""Exception raised when VWS returns a server error."""
def __init__(self, response: Response) -> None:
"""
Args:
response: The response returned by Vuforia.
"""
super().__init__(response.text)
self._response = response
@property
def response(self) -> Response:
"""The response returned by Vuforia which included this error."""
return self._response