Skip to content

Commit 75614b0

Browse files
committed
feat(jsonrpcl): simplify error message formatting in JsonRPCProtocol for better readability in clients
1 parent fd1b89a commit 75614b0

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

packages/jsonrpc2/src/robotcode/jsonrpc2/protocol.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ def _handle_body(self, body: bytes, charset: str) -> None:
500500
raise
501501
except BaseException as e:
502502
self.__logger.exception(e)
503-
self.send_error(JsonRPCErrors.PARSE_ERROR, f"{type(e).__name__}: {e}")
503+
self.send_error(JsonRPCErrors.PARSE_ERROR, f"{e}")
504504

505505
def _handle_messages(self, iterator: Iterator[JsonRPCMessage]) -> None:
506506
for m in iterator:
@@ -786,6 +786,9 @@ def _received_request_done(self, message: JsonRPCRequest, t: asyncio.Future[Any]
786786
ex = t.exception()
787787
if ex is not None:
788788
self.__logger.exception(ex, exc_info=ex)
789+
if isinstance(ex, JsonRPCErrorException):
790+
raise ex
791+
789792
raise JsonRPCErrorException(
790793
JsonRPCErrors.INTERNAL_ERROR,
791794
f"{type(ex).__name__}: {ex}",
@@ -804,15 +807,15 @@ def _received_request_done(self, message: JsonRPCRequest, t: asyncio.Future[Any]
804807
except JsonRPCErrorException as e:
805808
self.send_error(
806809
e.code,
807-
e.message or f"{type(e).__name__}: {e}",
810+
e.message or f"{e}",
808811
id=message.id,
809812
data=e.data,
810813
)
811814
except BaseException as e:
812815
self.__logger.exception(e)
813816
self.send_error(
814817
JsonRPCErrors.INTERNAL_ERROR,
815-
f"{type(e).__name__}: {e}",
818+
f"{e}",
816819
id=message.id,
817820
)
818821

0 commit comments

Comments
 (0)