2014-11-03 14:21:20 +01:00
|
|
|
diff -r bfa6bee1a9e0 trytond/protocols/jsonrpc.py
|
|
|
|
--- a/trytond/trytond/protocols/jsonrpc.py Mon Oct 20 14:30:02 2014 +0200
|
|
|
|
+++ b/trytond/trytond/protocols/jsonrpc.py Mon Nov 03 13:32:30 2014 +0100
|
|
|
|
@@ -27,6 +27,7 @@
|
2014-01-16 12:23:53 +01:00
|
|
|
import json
|
|
|
|
import base64
|
|
|
|
import encodings
|
|
|
|
+import logging
|
|
|
|
try:
|
|
|
|
from cStringIO import StringIO
|
|
|
|
except ImportError:
|
2014-11-03 14:21:20 +01:00
|
|
|
@@ -136,7 +137,14 @@
|
2014-01-16 12:23:53 +01:00
|
|
|
existing method through subclassing is the prefered means
|
|
|
|
of changing method dispatch behavior.
|
|
|
|
"""
|
2014-11-03 14:21:20 +01:00
|
|
|
- rawreq = json.loads(data, object_hook=JSONDecoder())
|
2014-01-16 12:23:53 +01:00
|
|
|
+ try:
|
2014-11-03 14:21:20 +01:00
|
|
|
+ rawreq = json.loads(data, object_hook=JSONDecoder())
|
2014-01-16 12:23:53 +01:00
|
|
|
+ except:
|
|
|
|
+ exc_type, exc_value = sys.exc_info()[:2]
|
|
|
|
+ logging.getLogger('jsonrpc').warning(
|
|
|
|
+ 'Exception in JSONRPC dispatcher: %s (%s)\n %s'
|
|
|
|
+ % (exc_value, exc_type, traceback.format_exc()))
|
|
|
|
+ raise
|
2014-11-03 14:21:20 +01:00
|
|
|
|
2014-01-16 12:23:53 +01:00
|
|
|
req_id = rawreq.get('id', 0)
|
|
|
|
method = rawreq['method']
|
2014-11-03 14:21:20 +01:00
|
|
|
@@ -152,11 +160,18 @@
|
2014-01-16 12:23:53 +01:00
|
|
|
response['result'] = self._dispatch(method, params)
|
|
|
|
except (UserError, UserWarning, NotLogged,
|
|
|
|
ConcurrencyException), exception:
|
|
|
|
+ logging.getLogger('jsonrpc').warning('User Error: %s (%s)'
|
|
|
|
+ % (method, params))
|
|
|
|
+ traceback.print_exc()
|
|
|
|
response['error'] = exception.args
|
|
|
|
except Exception:
|
|
|
|
+ exc_type, exc_value = sys.exc_info()[:2]
|
|
|
|
tb_s = ''.join(traceback.format_exception(*sys.exc_info()))
|
|
|
|
for path in sys.path:
|
|
|
|
tb_s = tb_s.replace(path, '')
|
|
|
|
+ logging.getLogger('jsonrpc').warning(
|
|
|
|
+ 'Exception in JSONRPC response generation: %s (%s)\n %s'
|
|
|
|
+ % (exc_value, exc_type, tb_s))
|
2014-11-03 14:21:20 +01:00
|
|
|
# report exception back to server
|
|
|
|
response['error'] = (str(sys.exc_value), tb_s)
|
2014-01-16 12:23:53 +01:00
|
|
|
|