diff options
| author | termie <github@anarkystic.com> | 2011-03-24 12:42:47 -0700 |
|---|---|---|
| committer | termie <github@anarkystic.com> | 2011-03-24 12:42:47 -0700 |
| commit | 4a6db815b01c71076bae96c155396e5adbe8af90 (patch) | |
| tree | 9e8c7690b71b55ca3983e3a48f19c8695f2daefb /nova/api | |
| parent | a1bde64e91a8b76fd0e69c3bdfc51e4e85adf6f0 (diff) | |
better error handling and serialization
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/direct.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/nova/api/direct.py b/nova/api/direct.py index 2e158e89e..bb2ace1c9 100644 --- a/nova/api/direct.py +++ b/nova/api/direct.py @@ -38,6 +38,7 @@ import routes import webob from nova import context +from nova import exception from nova import flags from nova import utils from nova import wsgi @@ -205,10 +206,12 @@ class ServiceWrapper(wsgi.Controller): # NOTE(vish): make sure we have no unicode keys for py2.6. params = dict([(str(k), v) for (k, v) in params.iteritems()]) result = method(context, **params) - if type(result) is dict or type(result) is list: - return self._serialize(result, req.best_match_content_type()) - else: + if result is None or type(result) is str or type(result) is unicode: return result + try: + return self._serialize(result, req.best_match_content_type()) + except: + raise exception.Error("returned non-serializable type: %s" % result) class Limited(object): |
