Skip to content

Commit 9faac72

Browse files
committed
Continue moving around where exceptions are
1 parent dc96955 commit 9faac72

File tree

6 files changed

+35
-14
lines changed

6 files changed

+35
-14
lines changed

src/vws/exceptions/base_exceptions.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
"""
2+
Base exceptions for errors returned by Vuforia Web Services or the Vuforia
3+
Cloud Recognition Web API.
4+
"""
5+
16
from requests import Response
27

38

@@ -24,15 +29,18 @@ def response(self) -> Response:
2429

2530
class VWSException(Exception):
2631
"""
27-
Base class for Vuforia Web Service errors.
32+
Base class for Vuforia Web Services errors.
33+
34+
These errors are defined at
35+
https://library.vuforia.com/articles/Solution/How-To-Use-the-Vuforia-Web-Services-API#How-To-Interperete-VWS-API-Result-Codes.
2836
"""
2937

3038
def __init__(self, response: Response) -> None:
3139
"""
3240
Args:
3341
response: The response to a request to Vuforia.
3442
"""
35-
super().__init__(response.text)
43+
super().__init__()
3644
self._response = response
3745

3846
@property

src/vws/exceptions/cloud_reco_exceptions.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
"""
2+
Exceptions which match errors raised by the Vuforia Cloud Recognition Web APIs.
3+
"""
4+
5+
16
from vws.exceptions.base_exceptions import CloudRecoException
27

38

src/vws/exceptions/custom_exceptions.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
"""
2+
Exceptions which do not map to errors at
3+
https://library.vuforia.com/articles/Solution/How-To-Use-the-Vuforia-Web-Services-API#How-To-Interperete-VWS-API-Result-Codes
4+
or simple errors given by the cloud recognition service.
5+
"""
6+
17
import requests
28

39

tests/test_exceptions.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,33 @@
1414
from mock_vws.states import States
1515

1616
from vws import VWS, CloudRecoService
17-
from vws.exceptions import (
17+
from vws.exceptions.base_exceptions import CloudRecoException, VWSException
18+
from vws.exceptions.cloud_reco_exceptions import (
19+
MatchProcessing,
20+
MaxNumResultsOutOfRange,
21+
)
22+
from vws.exceptions.custom_exceptions import (
23+
ConnectionErrorPossiblyImageTooLarge,
24+
TargetProcessingTimeout,
25+
UnknownVWSErrorPossiblyBadName,
26+
)
27+
from vws.exceptions.vws_exceptions import (
1828
AuthenticationFailure,
1929
BadImage,
20-
CloudRecoException,
21-
ConnectionErrorPossiblyImageTooLarge,
2230
DateRangeError,
2331
Fail,
2432
ImageTooLarge,
25-
MatchProcessing,
26-
MaxNumResultsOutOfRange,
2733
MetadataTooLarge,
2834
ProjectHasNoAPIAccess,
2935
ProjectInactive,
3036
ProjectSuspended,
3137
RequestQuotaReached,
3238
RequestTimeTooSkewed,
3339
TargetNameExist,
34-
TargetProcessingTimeout,
3540
TargetQuotaReached,
3641
TargetStatusNotSuccess,
3742
TargetStatusProcessing,
3843
UnknownTarget,
39-
UnknownVWSErrorPossiblyBadName,
40-
VWSException,
4144
)
4245

4346

@@ -368,7 +371,6 @@ def test_vwsexception_inheritance() -> None:
368371
TargetStatusNotSuccess,
369372
TargetStatusProcessing,
370373
UnknownTarget,
371-
UnknownVWSErrorPossiblyBadName,
372374
]
373375
for subclass in subclasses:
374376
assert issubclass(subclass, VWSException)

tests/test_query.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
from mock_vws.database import VuforiaDatabase
1111

1212
from vws import VWS, CloudRecoService
13-
from vws.exceptions import (
13+
from vws.exceptions.cloud_reco_exceptions import MaxNumResultsOutOfRange
14+
from vws.exceptions.custom_exceptions import (
1415
ConnectionErrorPossiblyImageTooLarge,
15-
MaxNumResultsOutOfRange,
1616
)
1717
from vws.include_target_data import CloudRecoIncludeTargetData
1818

tests/test_vws.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from mock_vws.database import VuforiaDatabase
1616

1717
from vws import VWS, CloudRecoService
18-
from vws.exceptions import TargetProcessingTimeout
18+
from vws.exceptions.custom_exceptions import TargetProcessingTimeout
1919
from vws.reports import (
2020
DatabaseSummaryReport,
2121
TargetRecord,

0 commit comments

Comments
 (0)