Skip to content

Commit 5f53fcd

Browse files
authored
Merge pull request tcalmant#31 from ybrustin/master
fix returned exception in case of several lines in error
2 parents f65afc1 + 30dc954 commit 5f53fcd

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

jsonrpclib/SimpleJSONRPCServer.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,8 @@ def _dispatch(self, method, params, config=None):
384384
return fault
385385
except:
386386
# Method exception
387-
err_lines = traceback.format_exc().splitlines()
388-
trace_string = '{0} | {1}'.format(err_lines[-3], err_lines[-1])
387+
err_lines = traceback.format_exception(*sys.exc_info())
388+
trace_string = '{0} | {1}'.format(err_lines[-2].splitlines()[0].strip(), err_lines[-1])
389389
fault = Fault(-32603, 'Server error: {0}'.format(trace_string),
390390
config=config)
391391
_logger.exception("Server-side exception: %s", fault)
@@ -451,8 +451,8 @@ def do_POST(self):
451451
except:
452452
# Exception: send 500 Server Error
453453
self.send_response(500)
454-
err_lines = traceback.format_exc().splitlines()
455-
trace_string = '{0} | {1}'.format(err_lines[-3], err_lines[-1])
454+
err_lines = traceback.format_exception(*sys.exc_info())
455+
trace_string = '{0} | {1}'.format(err_lines[-2].splitlines()[0].strip(), err_lines[-1])
456456
fault = jsonrpclib.Fault(-32603, 'Server error: {0}'
457457
.format(trace_string), config=config)
458458
_logger.exception("Server-side error: %s", fault)

0 commit comments

Comments
 (0)