Skip to content

Commit

Permalink
Separate, update, and improve exceptions documentation
Browse files Browse the repository at this point in the history
Automatically use docstrings for documentation
  • Loading branch information
Harmon758 committed Apr 11, 2021
1 parent 9242d88 commit 8a831b1
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 29 deletions.
29 changes: 0 additions & 29 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -281,35 +281,6 @@ Get app rate limit status
.. automethod:: API.rate_limit_status


:mod:`tweepy.error` --- Exceptions
==================================

The exceptions are available in the ``tweepy`` module directly, which means
``tweepy.error`` itself does not need to be imported. For example,
``tweepy.error.TweepError`` is available as ``tweepy.TweepError``.


.. exception:: TweepError

The main exception Tweepy uses. Is raised for a number of things.

When a ``TweepError`` is raised due to an error Twitter responded with,
the error code (`as described in the API documentation
<https://developer.twitter.com/en/docs/basics/response-codes>`_) can be
accessed at ``TweepError.response.text``. Note, however, that
``TweepError``\ s also may be raised with other things as message
(for example plain error reason strings).


.. exception:: RateLimitError

Is raised when an API method fails due to hitting Twitter's rate limit.
Makes for easy handling of the rate limit specifically.

Inherits from :exc:`TweepError`, so ``except TweepError`` will catch a
``RateLimitError`` too.


.. rubric:: Footnotes

.. [#] https://web.archive.org/web/20170829051949/https://dev.twitter.com/rest/reference/get/search/tweets
Expand Down
30 changes: 30 additions & 0 deletions docs/exceptions.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.. _exceptions:

.. currentmodule:: tweepy

**********
Exceptions
**********

.. autoexception:: TweepyException

.. autoexception:: HTTPException
:show-inheritance:

.. autoexception:: BadRequest
:show-inheritance:

.. autoexception:: Unauthorized
:show-inheritance:

.. autoexception:: Forbidden
:show-inheritance:

.. autoexception:: NotFound
:show-inheritance:

.. autoexception:: TooManyRequests
:show-inheritance:

.. autoexception:: TwitterServerError
:show-inheritance:
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Contents:
extended_tweets.rst
streaming_how_to.rst
api.rst
exceptions.rst
running_tests.rst

Indices and tables
Expand Down

0 comments on commit 8a831b1

Please sign in to comment.