Skip to content

Commit

Permalink
chore: add detail to encoding TypeError (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
BobTheBuidler authored Mar 9, 2024
1 parent 479f745 commit 7d1a375
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion dank_mids/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,16 @@ def __repr__(self) -> str:
def data(self) -> bytes:
if not self.calls:
raise EmptyBatch(f"batch {self.uid} is empty and should not be processed.")
return msgspec.json.encode([call.request for call in self.calls])
try:
return msgspec.json.encode([call.request for call in self.calls])
except TypeError:
# If we can't encode one of the calls, lets figure out which one and pass some useful info downstream
for call in self.calls:
try:
msgspec.json.encode(call.request)
except TypeError as e:
raise TypeError(e, call.request) from None
raise

@property
def is_multicalls_only(self) -> bool:
Expand Down

0 comments on commit 7d1a375

Please sign in to comment.