summaryrefslogtreecommitdiff
path: root/ironic_python_agent/errors.py
diff options
context:
space:
mode:
authorAlexander Gordeev <agordeev@mirantis.com>2014-05-05 15:49:03 +0400
committerAlexander Gordeev <agordeev@mirantis.com>2014-05-06 18:02:45 +0400
commited4460990e9e71994c631dde545f50005b5ef769 (patch)
tree09e1e1b085b0d24f1dbda1dd4558a927a9fc2261 /ironic_python_agent/errors.py
parentf95c8a9e6d6bb2a9c834b0bd8c4819bf25815af8 (diff)
downloadironic-python-agent-ed4460990e9e71994c631dde545f50005b5ef769.tar.gz
Make encoding.serialize() more programmatical
Introduce `serializable_fields` to express which class attributes to be serialized. Get rid of OrderedDict. Just replacing it with regular dict. Change-Id: I3f7639dab171d3d62e92d0d1bb6d7b071cf963ad
Diffstat (limited to 'ironic_python_agent/errors.py')
-rw-r--r--ironic_python_agent/errors.py14
1 files changed, 5 insertions, 9 deletions
diff --git a/ironic_python_agent/errors.py b/ironic_python_agent/errors.py
index 151d8cea..0cb9ad4a 100644
--- a/ironic_python_agent/errors.py
+++ b/ironic_python_agent/errors.py
@@ -13,7 +13,6 @@
# limitations under the License.
from ironic_python_agent import encoding
-from ironic_python_agent import utils
class RESTError(Exception, encoding.Serializable):
@@ -21,15 +20,12 @@ class RESTError(Exception, encoding.Serializable):
message = 'An error occurred'
details = 'An unexpected error occurred. Please try back later.'
status_code = 500
+ serializable_fields = ('type', 'code', 'message', 'details')
- def serialize(self):
- """Turn a RESTError into a dict."""
- return utils.get_ordereddict([
- ('type', self.__class__.__name__),
- ('code', self.status_code),
- ('message', self.message),
- ('details', self.details),
- ])
+ def __init__(self, *args, **kwargs):
+ super(RESTError, self).__init__(*args, **kwargs)
+ self.type = self.__class__.__name__
+ self.code = self.status_code
class InvalidContentError(RESTError):