diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2011-04-18 16:14:08 +0200 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2011-04-18 16:14:08 +0200 |
commit | 6eca2eb9a06d0991fa0f431839e528177313566a (patch) | |
tree | 44960d1c0f417cd9c989428317b937d89f6686b7 | |
parent | 6cc36efa70ff179de1468c8cfe614152366fa27b (diff) |
Try to show better Twitter error messages. Sadly this doesn't always work
since Twitter can't seem to make up their mind on the formatting of their
error responses, sometimes using XML and sometimes plain text.
-rw-r--r-- | protocols/twitter/twitter.c | 4 | ||||
-rw-r--r-- | protocols/twitter/twitter.h | 3 | ||||
-rw-r--r-- | protocols/twitter/twitter_lib.c | 6 |
3 files changed, 7 insertions, 6 deletions
diff --git a/protocols/twitter/twitter.c b/protocols/twitter/twitter.c index 50bf6cd2..a74250bf 100644 --- a/protocols/twitter/twitter.c +++ b/protocols/twitter/twitter.c @@ -150,7 +150,7 @@ static gboolean twitter_oauth_callback( struct oauth_info *info ) if( info->request_token == NULL ) { - imcb_error( ic, "OAuth error: %s", info->http->status_string ); + imcb_error( ic, "OAuth error: %s", twitter_parse_error( info->http ) ); imc_logout( ic, TRUE ); return FALSE; } @@ -166,7 +166,7 @@ static gboolean twitter_oauth_callback( struct oauth_info *info ) { if( info->token == NULL || info->token_secret == NULL ) { - imcb_error( ic, "OAuth error: %s", info->http->status_string ); + imcb_error( ic, "OAuth error: %s", twitter_parse_error( info->http ) ); imc_logout( ic, TRUE ); return FALSE; } diff --git a/protocols/twitter/twitter.h b/protocols/twitter/twitter.h index 5bce97d4..a3b21a07 100644 --- a/protocols/twitter/twitter.h +++ b/protocols/twitter/twitter.h @@ -84,4 +84,7 @@ extern GSList *twitter_connections; void twitter_login_finish( struct im_connection *ic ); +struct http_request; +char *twitter_parse_error( struct http_request *req ); + #endif //_TWITTER_H diff --git a/protocols/twitter/twitter_lib.c b/protocols/twitter/twitter_lib.c index e8fb3530..472ce944 100644 --- a/protocols/twitter/twitter_lib.c +++ b/protocols/twitter/twitter_lib.c @@ -141,7 +141,7 @@ static void twitter_add_buddy(struct im_connection *ic, char *name, const char * /* Warning: May return a malloc()ed value, which will be free()d on the next call. Only for short-term use. */ -static char *twitter_parse_error(struct http_request *req) +char *twitter_parse_error(struct http_request *req) { static char *ret = NULL; struct xt_parser *xp = NULL; @@ -160,14 +160,12 @@ static char *twitter_parse_error(struct http_request *req) node->text_len > 0) { ret = g_strdup_printf("%s (%s)", req->status_string, node->text); - xt_free(xp); - return ret; } xt_free(xp); } - return req->status_string; + return ret ? ret : req->status_string; } static void twitter_http_get_friends_ids(struct http_request *req); |