(self, json_response)
Raises the best exception for a json response.
Raises the best exception for a json response.
Raises the best exception for a json response .
def raise_best_exception(self, json_response):
        """Raises the best exception for a json response."""
        exceptions = {
                206: CannotParseError,
                400: BadRequestError,
                401: NotAuthorizedError,
                403: ForbiddenError,
                404: NotFoundError,
                500: ServerError,
                503: UnavailableError,
        }
        try:
            err = json_response['response']['error']
            raise exceptions[err['code']](err['code'],err['message'])
        except IndexError:
            raise UnexpectedError('','Unexpected error.')
def raise_best_exception ( self , json_response ) : exceptions = { 206 : CannotParseError , 400 : BadRequestError , 401 : NotAuthorizedError , 403 : ForbiddenError , 404 : NotFoundError , 500 : ServerError , 503 : UnavailableError , } try : err = json_response [ 'response' ] [ 'error' ] raise exceptions [ err [ 'code' ] ] ( err [ 'code' ] , err [ 'message' ] ) except IndexError : raise UnexpectedError ( '' , 'Unexpected error.' )