hoonsbara / wittytwitter

Automatically exported from code.google.com/p/wittytwitter
0 stars 0 forks source link

Improve Error handling #28

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Don't crash the app when encountering standard errors.

IDEA: maybe have a global error handler that logs the error.

Original issue reported on code.google.com by alan...@gmail.com on 25 Oct 2007 at 7:42

GoogleCodeExporter commented 8 years ago
Agreed, Witty bombs on an HTTP error code 503 (which is server/service is down).
Since Twitter has some stability issues it's probably best to catch those 
errors.

Original comment by jtuc...@gmail.com on 31 Jan 2008 at 6:48

GoogleCodeExporter commented 8 years ago
good point.

Need to add case for error code 503 to this code in TwitterNet.cs

                        switch ((int)httpResponse.StatusCode)
                        {
                            case 304:  // 304 Not modified = no new tweets so ignore
error.
                                break;
                            case 400: // rate limit exceeded
                                throw new RateLimitException("Rate limit exceeded.
Clients may not make more than 70 requests per hour. Please try again in a few
minutes.");
                            case 401: // unauthorized
                                throw new SecurityException("Not Authorized.");
                            default:
                                throw;
                        }

Original comment by alan...@gmail.com on 31 Jan 2008 at 9:11

GoogleCodeExporter commented 8 years ago
maybe add a general strategy to write errors to the event log or a .log file. 
This
sort of stuff is not my forte. 

Original comment by alan...@gmail.com on 1 Feb 2008 at 9:50

GoogleCodeExporter commented 8 years ago
right now the exception handling is not very DRY.

Original comment by alan...@gmail.com on 1 Feb 2008 at 9:50

GoogleCodeExporter commented 8 years ago
What about adding in log4net for logging? Info on how to add log4net to a 
Winform app
here: 
http://anthony-yio.blogspot.com/2005/01/log4net-tutorial-my-straightforward.html

Also, might be nice to add in a global unhandled exception handler in App.xaml -
http://msdn2.microsoft.com/en-us/library/system.windows.application.dispatcherun
handledexception.aspx
The the error could be logged and noted in the status bar, but the app wouldn't 
need
to crash.

What do you think?

Original comment by jongallo...@gmail.com on 3 Feb 2008 at 5:56

GoogleCodeExporter commented 8 years ago
i'm hoping someone more knowledgeable about it can do this.  it'll free me up to
concentrate more on UI, skins, visualizations.

Original comment by alan...@gmail.com on 3 Feb 2008 at 9:16

GoogleCodeExporter commented 8 years ago
just noticed that twitter has updated their API documentation with the http 
error
codes that they return:
http://groups.google.com/group/twitter-development-talk/web/api-documentation

HTTP Status Codes

The Twitter API attempts to return appropriate HTTP status codes for every 
request.
Here's what's going on with our various status codes:

    * 200 OK: everything went awesome.
    * 304 Not Modified: there was no new data to return.
    * 400 Bad Request: your request is invalid, and we'll return an error message
that tells you why. This is the status code returned if you've exceeded the rate
limit (see below). 
    * 401 Not Authorized: either you need to provide authentication credentials, or
the credentials provided aren't valid.
    * 403 Forbidden: we understand your request, but are refusing to fulfill it.  An
accompanying error message should explain why.
    * 404 Not Found: either you're requesting an invalid URI or the resource in
question doesn't exist (ex: no such user). 
    * 500 Internal Server Error: we did something wrong.  Please post to the group
about it and the Twitter team will investigate.
    * 502 Bad Gateway: returned if Twitter is down or being upgraded.
    * 503 Service Unavailable: the Twitter servers are up, but are overloaded with
requests.  Try again later.

When the Twitter API returns error messages, it attempts to do in your requested
format.  For example, an error from an XML method might look like this:

<?xml version="1.0" encoding="UTF-8"?>
<hash>
  <request>/direct_messages/destroy/456.xml</request>
  <error>No direct message with that ID found.</error>
</hash>  

Original comment by alan...@gmail.com on 4 Feb 2008 at 5:59

GoogleCodeExporter commented 8 years ago
I added log4net as the new log handler for exceptions.  Basic logging has been 
added
in the main app only as of this time.  Former #if DEBUG sections have been 
replaced
with logger.debug(...) statements which write to a text file in the Witty bin 
folder.
 I will open a discussion for further logging changes.  All developers will need to
install the current log4net version (1.2 Beta) at it's current default location 
of
...\Program Files\log4net-1.2.0-beta8\...  

Original comment by Daniel.B...@gmail.com on 12 Mar 2008 at 9:49

GoogleCodeExporter commented 8 years ago
One of the things I thought would be good for Witty is a visual notification of 
an
error. Instead of a MsgBox, maybe have the update panel or maybe the top black 
bar,
turn red and display a user-friend error message?

Original comment by scottck...@gmail.com on 20 Mar 2008 at 10:23