From 5d9f17d414534f36f88689194d83f45b601345b2 Mon Sep 17 00:00:00 2001 From: Tim Nyborg Date: Tue, 9 Oct 2018 10:51:38 +0100 Subject: [PATCH] correct rendering of jsonrpcerrors Currently, JSONRPCErrors get spit into a console or ticket one line per character (due to the '\n'.join(data) applying to a string). This fixes that issue while preserving new lines for arrays. --- gluon/contrib/simplejsonrpc.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gluon/contrib/simplejsonrpc.py b/gluon/contrib/simplejsonrpc.py index 13bcf2b4..23301081 100644 --- a/gluon/contrib/simplejsonrpc.py +++ b/gluon/contrib/simplejsonrpc.py @@ -34,7 +34,9 @@ import json class JSONRPCError(RuntimeError): "Error object for remote procedure call fail" - def __init__(self, code, message, data=''): + def __init__(self, code, message, data=''): + if isinstance(data, basestring): + data = [data] value = "%s: %s\n%s" % (code, message, '\n'.join(data)) RuntimeError.__init__(self, value) self.code = code