From e14f9741a6fedc2ed4cddd304b2f86378b707575 Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Fri, 11 Jul 2014 13:29:34 -0400 Subject: [PATCH] Revert "Set default http-based exception as `HttpError`" This reverts commit 4e1ee661083bd672a884fd13fdb1ffaadea5252a. This change is a part of a series that is not backwards compatible, and caused breakage in applications that use the client library. Change-Id: If614826fb0832602110c1ac8be2c0e6324a5a248 Partial-Bug: #1340596 --- novaclient/base.py | 2 +- novaclient/exceptions.py | 14 ++------------ 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/novaclient/base.py b/novaclient/base.py index 6b000f8fe..a677e3229 100644 --- a/novaclient/base.py +++ b/novaclient/base.py @@ -139,7 +139,7 @@ class ManagerWithFind(Manager): num_matches = len(matches) if num_matches == 0: msg = "No %s matching %s." % (self.resource_class.__name__, kwargs) - raise exceptions.NotFound(msg) + raise exceptions.NotFound(404, msg) elif num_matches > 1: raise exceptions.NoUniqueMatch else: diff --git a/novaclient/exceptions.py b/novaclient/exceptions.py index 73f04dcef..6c1c2deba 100644 --- a/novaclient/exceptions.py +++ b/novaclient/exceptions.py @@ -28,15 +28,6 @@ from novaclient.openstack.common.apiclient.exceptions import * # noqa OverLimit = RequestEntityTooLarge -def _deprecate_code_attribute(slf): - import warnings - warnings.warn("'code' attribute is deprecated since v.2.17.0. Use " - "'http_status' instead of this one.", UserWarning) - return slf.http_status - -HttpError.code = property(_deprecate_code_attribute) - - class NoTokenLookupException(ClientException): """This form of authentication does not support looking up endpoints from an existing token. @@ -76,7 +67,7 @@ class InvalidUsage(RuntimeError): def from_response(response, body, url, method=None): """ - Return an instance of an HttpError or subclass + Return an instance of an ClientException or subclass based on an requests response. Usage:: @@ -110,6 +101,5 @@ def from_response(response, body, url, method=None): kwargs['message'] = message kwargs['details'] = details - cls = _code_map.get(response.status_code, HttpError) - + cls = _code_map.get(response.status_code, ClientException) return cls(**kwargs)