web/views/basecontrollers.py
branchstable
changeset 6683 68cfebd3b9f3
parent 6619 ed5b452506af
child 6684 b8bd0ecced2e
--- a/web/views/basecontrollers.py	Fri Nov 05 12:43:25 2010 +0100
+++ b/web/views/basecontrollers.py	Fri Nov 05 14:28:07 2010 +0100
@@ -27,6 +27,7 @@
 from cubicweb import (NoSelectableObject, ObjectNotFound, ValidationError,
                       AuthenticationError, typed_eid)
 from cubicweb.utils import UStringIO, json, json_dumps
+from cubicweb.uilib import exc_message
 from cubicweb.selectors import authenticated_user, anonymous_user, match_form_params
 from cubicweb.mail import format_mail
 from cubicweb.web import Redirect, RemoteCallFailed, DirectResponse
@@ -281,15 +282,15 @@
         except ValueError, exc:
             self.exception('error while decoding json arguments for js_%s: %s',
                            fname, args, exc)
-            raise RemoteCallFailed(repr(exc))
+            raise RemoteCallFailed(exc_message(exc, self._cw.encoding))
         try:
             result = func(*args)
         except (RemoteCallFailed, DirectResponse):
             raise
-        except Exception, ex:
+        except Exception, exc:
             self.exception('an exception occurred while calling js_%s(%s): %s',
-                           fname, args, ex)
-            raise RemoteCallFailed(repr(ex))
+                           fname, args, exc)
+            raise RemoteCallFailed(exc_message(exc, self._cw.encoding))
         if result is None:
             return ''
         # get unicode on @htmlize methods, encoded string on @jsonize methods