Skip to content

Commit 90911eb

Browse files
committed
Use autoexception in docs
1 parent b69cc9c commit 90911eb

File tree

3 files changed

+16
-47
lines changed

3 files changed

+16
-47
lines changed

docs/client/overview.rst

Lines changed: 7 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -573,46 +573,13 @@ Modifying tags is available on spider/job levels.
573573
Exceptions
574574
----------
575575

576-
scrapinghub.exceptions.ScrapinghubAPIError
577-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
578-
579-
Base exception class for all other exceptions listed below.
580-
581-
582-
scrapinghub.exceptions.BadRequest
583-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
584-
585-
Usually raised in case of 400 response from API.
586-
587-
588-
scrapinghub.exceptions.Unauthorized
589-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
590-
591-
Not enough access to some resources.
592-
593-
594-
scrapinghub.exceptions.NotFound
595-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
596-
597-
Entity doesn't exist (e.g. spider or project).
598-
599-
600-
scrapinghub.exceptions.ValueTooLarge
601-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
602-
603-
Value cannot be writtent because it exceeds size limits.
604-
605-
606-
scrapinghub.exceptions.DuplicateJobError
607-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
608-
609-
Job for given spider with given arguments is already scheduled or running.
610-
611-
612-
scrapinghub.exceptions.ServerError
613-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
614-
615-
Indicates some server error: something unexpected has happened.
576+
.. autoexception:: scrapinghub.ScrapinghubAPIError
577+
.. autoexception:: scrapinghub.BadRequest
578+
.. autoexception:: scrapinghub.Unauthorized
579+
.. autoexception:: scrapinghub.NotFound
580+
.. autoexception:: scrapinghub.ValueTooLarge
581+
.. autoexception:: scrapinghub.DuplicateJobError
582+
.. autoexception:: scrapinghub.ServerError
616583

617584

618585
.. _Scrapinghub API: http://doc.scrapinghub.com/api.html

scrapinghub/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
__all__ = ["APIError", "Connection", "HubstorageClient",
22
"ScrapinghubClient", "ScrapinghubAPIError",
33
"DuplicateJobError", "BadRequest", "NotFound",
4-
"Unauthorized", "ValueTooLarge"]
4+
"Unauthorized", "ValueTooLarge", "ServerError"]
55

66
import pkgutil
77
__version__ = pkgutil.get_data(__package__, 'VERSION')
@@ -19,4 +19,5 @@
1919
NotFound,
2020
Unauthorized,
2121
ValueTooLarge,
22+
ServerError,
2223
)

scrapinghub/client/exceptions.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def _get_http_error_msg(exc):
2424

2525

2626
class ScrapinghubAPIError(Exception):
27+
"""Base exception class."""
2728

2829
def __init__(self, message=None, http_error=None):
2930
self.http_error = http_error
@@ -33,27 +34,27 @@ def __init__(self, message=None, http_error=None):
3334

3435

3536
class BadRequest(ScrapinghubAPIError):
36-
pass
37+
"""Usually raised in case of 400 response from API."""
3738

3839

3940
class Unauthorized(ScrapinghubAPIError):
40-
pass
41+
"""Request lacks valid authentication credentials for the target resource."""
4142

4243

4344
class NotFound(ScrapinghubAPIError):
44-
pass
45+
"""Entity doesn't exist (e.g. spider or project)."""
4546

4647

4748
class ValueTooLarge(ScrapinghubAPIError):
48-
pass
49+
"""Value cannot be writtent because it exceeds size limits."""
4950

5051

5152
class DuplicateJobError(ScrapinghubAPIError):
52-
pass
53+
"""Job for given spider with given arguments is already scheduled or running."""
5354

5455

5556
class ServerError(ScrapinghubAPIError):
56-
pass
57+
"""Indicates some server error: something unexpected has happened."""
5758

5859

5960
def wrap_http_errors(method):

0 commit comments

Comments
 (0)