diff options
| author | Jenkins <jenkins@review.openstack.org> | 2013-07-23 13:28:25 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2013-07-23 13:28:25 +0000 |
| commit | 53bd102c75ee5040323b47e14ad9b3faae6db6eb (patch) | |
| tree | 27c41112013a57e38b78e0c1a90585e5d7216f7e /openstack | |
| parent | 9a0eea8749aecff040b2be446a80c53013dc6602 (diff) | |
| parent | 9a3ebf2ff5b995085d0fb8e075687b48681d391f (diff) | |
| download | oslo-53bd102c75ee5040323b47e14ad9b3faae6db6eb.tar.gz oslo-53bd102c75ee5040323b47e14ad9b3faae6db6eb.tar.xz oslo-53bd102c75ee5040323b47e14ad9b3faae6db6eb.zip | |
Merge "Avoid shadowing Exception 'message' attribute"
Diffstat (limited to 'openstack')
| -rw-r--r-- | openstack/common/exception.py | 22 |
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" |
