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:
parent
c87177e7a6
commit
68158d1053
@ -30,7 +30,16 @@ class TLObject:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def read(cls, data: BytesIO, *args: Any) -> Any:
|
def read(cls, data: BytesIO, *args: Any) -> Any:
|
||||||
return cast(TLObject, objects[int.from_bytes(data.read(4), "little")]).read(data, *args)
|
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:
|
def write(self, *args: Any) -> bytes:
|
||||||
pass
|
pass
|
||||||
|
Loading…
x
Reference in New Issue
Block a user