From 47e170b273d6558647fa9f169e48fb2b6ba632e8 Mon Sep 17 00:00:00 2001 From: BobTheBuidler Date: Sun, 1 Sep 2024 23:53:04 +0000 Subject: [PATCH] chore: add debugging details to msgspec.ValidationError --- dank_mids/types.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dank_mids/types.py b/dank_mids/types.py index 5dd21804..5bde15f7 100644 --- a/dank_mids/types.py +++ b/dank_mids/types.py @@ -294,7 +294,11 @@ def decode(self, partial: Literal[True]) -> PartialResponse:... def decode(self, partial: Literal[False] = False) -> Response:... def decode(self, partial: bool = False) -> Union[Response, PartialResponse]: """Decode the wrapped `msgspec.Raw` object into a `Response` or a `PartialResponse`.""" - return msgspec.json.decode(self._raw, type=PartialResponse if partial else Response) + try: + return msgspec.json.decode(self._raw, type=PartialResponse if partial else Response) + except msgspec.ValidationError as e: + e.args = (*e.args, f"decoded: {msgspec.json.decode(self._raw)}") + raise JSONRPCBatchRequest = List[Request] # NOTE: A PartialResponse result implies a failure response from the rpc.