[Kimchi-devel] [PATCH] Exception: fix exception details when not specified
lvroyce at linux.vnet.ibm.com
lvroyce at linux.vnet.ibm.com
Thu May 15 11:23:24 UTC 2014
From: Royce Lv <lvroyce at linux.vnet.ibm.com>
Not every validation error needs to translate for user,
we define user interested errors,
other developer interested error should report directly by schema validator,
and handled by developer directly.
fix exception handling for this situation.
Signed-off-by: Royce Lv <lvroyce at linux.vnet.ibm.com>
Signed-off-by: Zhou Zheng Sheng <zhshzhou at linux.vnet.ibm.com>
---
src/kimchi/control/utils.py | 6 ++++--
src/kimchi/exception.py | 2 +-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/kimchi/control/utils.py b/src/kimchi/control/utils.py
index 5e63816..a67f627 100644
--- a/src/kimchi/control/utils.py
+++ b/src/kimchi/control/utils.py
@@ -98,8 +98,10 @@ def validate_params(params, instance, action):
try:
validator.validate(request)
except ValidationError, e:
- raise InvalidParameter(e.schema['error'], {'value': str(e.instance)})
-
+ if e.schema.get('error'):
+ raise InvalidParameter(e.schema['error'], {'value': str(e.instance)})
+ else:
+ raise InvalidParameter(e.message)
class UrlSubNode(object):
diff --git a/src/kimchi/exception.py b/src/kimchi/exception.py
index fcf60cc..5a292e0 100644
--- a/src/kimchi/exception.py
+++ b/src/kimchi/exception.py
@@ -62,7 +62,7 @@ class KimchiException(Exception):
# itself to a unicode string.
args[key] = unicode(value)
- return unicode(translation.gettext(text), 'utf-8') % args
+ return translation.gettext(text).encode('utf-8') % args
class NotFoundError(KimchiException):
--
1.8.3.2
More information about the Kimchi-devel
mailing list