meebey / smuxi

Smuxi is an user-friendly and free IRC client for Linux, Windows and Mac OS X based on GNOME / GTK+
https://smuxi.im/
GNU General Public License v2.0
172 stars 46 forks source link

Engine-Twitter: set an error message when the user is not found #204

Open knocte opened 9 years ago

knocte commented 9 years ago

Set an error message when the user is not found, otherwise the error message shown to the user as "Reason" would be the useless "Exception of type 'Twitterizer.TwitterizerException' was thrown.", when launching a command such as /timeline non-existing-username.

meebey commented 9 years ago

I think this is a bug in Twitterizer that I need to fix. It should set the error message from Twitter but it doesn't, thus it fallbacks to the TypeName

knocte commented 9 years ago

@meebey, look at the whole if block:

            // HACK: Twitter returns HTML code saying they are overloaded o_O
            if (response.Result == RequestResult.Unknown &&
                response.ErrorMessage == null) {
                response.ErrorMessage = _("Twitter didn't send a valid response, they're probably overloaded");
            } else if (response.Result == RequestResult.FileNotFound &&
                response.ErrorMessage == null) {
                response.ErrorMessage = _("Twitter user not found");
            }

So it seems another case of ErrorMessage being null from the server.

meebey commented 9 years ago

Oh yeah, that could be. But IIRC they don't return specific error codes but 200, else the HTML page would not render in browsers.... but this new mapping makes the error message of your case nicer.

knocte commented 9 years ago

Actually, just debugged Twitterizer lib, and the response message is (in line 248 of TwitterCommand class):

twitterResponse.Content = "{\"errors\":[{\"message\":\"Sorry, that page does not exist\",\"code\":34}]}"

If one were to fix Twitterizer, the message is not much better than the one I used here!

meebey commented 9 years ago

Sso there is a Twitterizer bug, but even if that was fixed it would present a useless error message so the command needs to provide the message itself