summaryrefslogtreecommitdiffstats
path: root/openstack
diff options
context:
space:
mode:
authorBen Nemec <openstack@nemebean.com>2013-07-10 10:36:40 -0500
committerBen Nemec <openstack@nemebean.com>2013-07-19 10:17:00 -0500
commit9a3ebf2ff5b995085d0fb8e075687b48681d391f (patch)
tree1362a836233acf301db35f8b67863c0a7ddaa8ea /openstack
parent3c69baf5c8db4b98df93c8ef5702d7df095d69ff (diff)
downloadoslo-9a3ebf2ff5b995085d0fb8e075687b48681d391f.tar.gz
oslo-9a3ebf2ff5b995085d0fb8e075687b48681d391f.tar.xz
oslo-9a3ebf2ff5b995085d0fb8e075687b48681d391f.zip
Avoid shadowing Exception 'message' attribute
Exception.message is deprecated in Python 3, and it's confusing that we shadow it right now, so change class attributes named message to something else. For reference, see commit 7bfd4439fe48e861675e3930486b55f8badd072e Change-Id: I913a8a5d025cc392ef2003951763cf55629fd8d2
Diffstat (limited to 'openstack')
-rw-r--r--openstack/common/exception.py22
1 files changed, 11 insertions, 11 deletions
diff --git a/openstack/common/exception.py b/openstack/common/exception.py
index fdf17b2..2a9a751 100644
--- a/openstack/common/exception.py
+++ b/openstack/common/exception.py
@@ -33,7 +33,7 @@ class Error(Exception):
class ApiError(Error):
def __init__(self, message='Unknown', code='Unknown'):
- self.message = message
+ self.api_message = message
self.code = code
super(ApiError, self).__init__('%s: %s' % (code, message))
@@ -44,19 +44,19 @@ class NotFound(Error):
class UnknownScheme(Error):
- msg = "Unknown scheme '%s' found in URI"
+ msg_fmt = "Unknown scheme '%s' found in URI"
def __init__(self, scheme):
- msg = self.__class__.msg % scheme
+ msg = self.__class__.msg_fmt % scheme
super(UnknownScheme, self).__init__(msg)
class BadStoreUri(Error):
- msg = "The Store URI %s was malformed. Reason: %s"
+ msg_fmt = "The Store URI %s was malformed. Reason: %s"
def __init__(self, uri, reason):
- msg = self.__class__.msg % (uri, reason)
+ msg = self.__class__.msg_fmt % (uri, reason)
super(BadStoreUri, self).__init__(msg)
@@ -113,29 +113,29 @@ class OpenstackException(Exception):
"""Base Exception class.
To correctly use this class, inherit from it and define
- a 'message' property. That message will get printf'd
+ a 'msg_fmt' property. That message will get printf'd
with the keyword arguments provided to the constructor.
"""
- message = "An unknown exception occurred"
+ msg_fmt = "An unknown exception occurred"
def __init__(self, **kwargs):
try:
- self._error_string = self.message % kwargs
+ self._error_string = self.msg_fmt % kwargs
except Exception:
if _FATAL_EXCEPTION_FORMAT_ERRORS:
raise
else:
# at least get the core message out if something happened
- self._error_string = self.message
+ self._error_string = self.msg_fmt
def __str__(self):
return self._error_string
class MalformedRequestBody(OpenstackException):
- message = "Malformed message body: %(reason)s"
+ msg_fmt = "Malformed message body: %(reason)s"
class InvalidContentType(OpenstackException):
- message = "Invalid content type %(content_type)s"
+ msg_fmt = "Invalid content type %(content_type)s"