Example #1
0
    def is_server_error(cls, e, response):
        '''
        Checks an HTTPError to see if Facebook is down or we are using the
        API in the wrong way
        Facebook doesn't clearly distinquish between the two, so this is a bit
        of a hack
        '''
        from open_facebook.utils import is_json
        server_error = False
        if hasattr(e, 'code') and e.code == 500:
            server_error = True

        # Facebook status codes are used for application logic
        # http://fbdevwiki.com/wiki/Error_codes#User_Permission_Errors
        # The only way I know to detect an actual server error is to check if
        # it looks like their error page
        # TODO: think of a better solution....
        error_matchers = [
            '<title>Facebook | Error</title>',
            'Sorry, something went wrong.'
        ]
        is_error_page = all(
            [matcher in response for matcher in error_matchers])
        if is_error_page:
            server_error = True

        # if it looks like json, facebook is probably not down
        if is_json(response):
            server_error = False

        return server_error
Example #2
0
    def is_server_error(cls, e, response):
        '''
        Checks an HTTPError to see if Facebook is down or we are using the
        API in the wrong way
        Facebook doesn't clearly distinquish between the two, so this is a bit
        of a hack
        '''
        from open_facebook.utils import is_json
        server_error = False
        if hasattr(e, 'code') and e.code == 500:
            server_error = True

        # Facebook status codes are used for application logic
        # http://fbdevwiki.com/wiki/Error_codes#User_Permission_Errors
        # The only way I know to detect an actual server error is to check if
        # it looks like their error page
        # TODO: think of a better solution....
        error_matchers = [
            '<title>Facebook | Error</title>', 'Sorry, something went wrong.'
        ]
        is_error_page = all(
            [matcher in response for matcher in error_matchers])
        if is_error_page:
            server_error = True

        # if it looks like json, facebook is probably not down
        if is_json(response):
            server_error = False

        return server_error
Example #3
0
    def is_server_error(cls, e, response):
        '''
        Checks an HTTPError to see if Facebook is down or we are using the
        API in the wrong way
        Facebook doesn't clearly distinquish between the two, so this is a bit
        of a hack
        '''
        from open_facebook.utils import is_json
        server_error = False
        if hasattr(e, 'code') and e.code == 500:
            server_error = True

        # if it looks like json, facebook is probably not down
        if is_json(response):
            server_error = False

        return server_error