From: obskyr Date: Thu, 15 Oct 2015 13:50:30 +0000 (+0200) Subject: Added documentation for exceptions. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=a439c3d9a197ff6617da610615ea057d34d2e063;p=tweepy.git Added documentation for exceptions. --- diff --git a/docs/api.rst b/docs/api.rst index d89f25b..07143d8 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -777,3 +777,29 @@ Geo Methods Given *id* of a place, provide more details about that place. :param id: Valid Twitter ID of a location. + +: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 + `_) can be accessed + at ``TweepError.message[0]['code']``. 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.