'Parse the error messages.
Response body can easily be handled by this class parent
:class:`XmlResponse`, but there are use cases which Abiquo API
does not respond an XML but an HTML. So we need to
handle these special cases.'

def parse_error(self):

    if (self.status == httplib.UNAUTHORIZED):
        raise InvalidCredsError(driver=self.connection.driver)
    elif (self.status == httplib.FORBIDDEN):
        raise ForbiddenError(self.connection.driver)
    elif (self.status == httplib.NOT_ACCEPTABLE):
        raise LibcloudError('Not    Acceptable')
    else:
        parsebody = self.parse_body()
        if ((parsebody is not None) and hasattr(parsebody, 'findall')):
            errors = self.parse_body().findall('error')
            raise LibcloudError(errors[0].findtext('message'))
        else:
            raise LibcloudError(self.body)
