2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-29 13:27:47 +00:00

Add nicer error in case of unknown constructors

This commit is contained in:
Dan 2020-11-30 12:41:06 +01:00
parent c87177e7a6
commit 68158d1053

View File

@ -30,7 +30,16 @@ class TLObject:
@classmethod
def read(cls, data: BytesIO, *args: Any) -> Any:
try:
return cast(TLObject, objects[int.from_bytes(data.read(4), "little")]).read(data, *args)
except KeyError as e:
left = data.read()
left = [left[i:i + 64] for i in range(0, len(left), 64)]
left = [[left[i:i + 8] for i in range(0, len(left), 8)] for left in left]
left = "\n".join(" ".join(x for x in left) for left in left)
raise ValueError(f"Unknown constructor found: {hex(e.args[0])}\n{left}")
def write(self, *args: Any) -> bytes:
pass