From: Josh Roesslein Date: Sat, 8 Aug 2009 21:18:03 +0000 (-0500) Subject: Add tutorial 4 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=822db1a4217e0598469130b3b84f92979abf35d7;p=tweepy.git Add tutorial 4 --- diff --git a/tutorial/t4.py b/tutorial/t4.py new file mode 100644 index 0000000..1ee052a --- /dev/null +++ b/tutorial/t4.py @@ -0,0 +1,36 @@ +import tweepy + +""" Tutorial 4 -- Errors + +Errors are going to happen sooner or later in your applications. +This tutorial will show you how to properly catch these errors in +Tweepy and handle them gracefully in your application. +""" + +""" TweepError + +Tweepy uses a single exception: tweepy.TweepError. +When ever something goes wrong this exception will be raised. +Here is an example: +""" +try: + tweepy.api.update_status('this will fail since we are not authenticated!') +except tweepy.TweepError, e: + print 'Failed to update! %s' % e + +""" +TweepError's can be casted to string format which will +give details as to what wents wrong. +The main reasons an exception will be raised include: + + -HTTP request to twitter failed + -Model failed validation + -Trying to use an authenticated API endpoint w/o authenticating + -Invalid parameters supplied to API methods + -Authentication failures + +Be sure to keep a look out for these exceptions and handle them properly. +""" + +""" The End """ +