@staticmethod
def process_session(res):
    """Return (got_session, error_details).
        error_details is (should_retry, reason, error_code) or None if got_session."""
    if 'sessionStatus' in res:
        return True, None
    if 'errorMessage' in res:
        try:
            error_code = res['errorMessage']['additionalInfo'][
                'uploader_service.GoogleRupioAdditionalInfo']['completionInfo'
                ]['customerSpecificInfo']['ResponseCode']
        except KeyError:
            error_code = None
        got_session = False
        if error_code == 503:
            should_retry = True
            reason = 'upload servers still syncing'
        elif error_code == 200:
            should_retry = False
            reason = 'this song is already uploaded'
        elif error_code == 404:
            should_retry = False
            reason = 'the request was rejected'
        else:
            should_retry = True
            reason = 'the server reported an unknown error'
        return got_session, (should_retry, reason, error_code)
    return False, (True, "the server's response could not be understood", None)
