Changeset 6eca2eb for protocols/twitter


Ignore:
Timestamp:
2011-04-18T14:14:08Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
2423c93
Parents:
6cc36ef
Message:

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.

Location:
protocols/twitter
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • protocols/twitter/twitter.c

    r6cc36ef r6eca2eb  
    151151                if( info->request_token == NULL )
    152152                {
    153                         imcb_error( ic, "OAuth error: %s", info->http->status_string );
     153                        imcb_error( ic, "OAuth error: %s", twitter_parse_error( info->http ) );
    154154                        imc_logout( ic, TRUE );
    155155                        return FALSE;
     
    167167                if( info->token == NULL || info->token_secret == NULL )
    168168                {
    169                         imcb_error( ic, "OAuth error: %s", info->http->status_string );
     169                        imcb_error( ic, "OAuth error: %s", twitter_parse_error( info->http ) );
    170170                        imc_logout( ic, TRUE );
    171171                        return FALSE;
  • protocols/twitter/twitter.h

    r6cc36ef r6eca2eb  
    8585void twitter_login_finish( struct im_connection *ic );
    8686
     87struct http_request;
     88char *twitter_parse_error( struct http_request *req );
     89
    8790#endif //_TWITTER_H
  • protocols/twitter/twitter_lib.c

    r6cc36ef r6eca2eb  
    142142/* Warning: May return a malloc()ed value, which will be free()d on the next
    143143   call. Only for short-term use. */
    144 static char *twitter_parse_error(struct http_request *req)
     144char *twitter_parse_error(struct http_request *req)
    145145{
    146146        static char *ret = NULL;
     
    161161                {
    162162                        ret = g_strdup_printf("%s (%s)", req->status_string, node->text);
    163                         xt_free(xp);
    164                         return ret;
    165163                }
    166164               
     
    168166        }
    169167       
    170         return req->status_string;
     168        return ret ? ret : req->status_string;
    171169}
    172170
Note: See TracChangeset for help on using the changeset viewer.