mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-02-09 16:10:51 +03:00
Better logging for packing errors
https://github.com/expectocode/telegram-export/issues/76
This commit is contained in:
parent
e3bf6e3330
commit
d3efc8f57d
|
@ -1,10 +1,13 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import logging
|
||||||
import struct
|
import struct
|
||||||
|
|
||||||
from .gzippacked import GzipPacked
|
from .gzippacked import GzipPacked
|
||||||
from .. import TLObject
|
from .. import TLObject
|
||||||
from ..functions import InvokeAfterMsgRequest
|
from ..functions import InvokeAfterMsgRequest
|
||||||
|
|
||||||
|
__log__ = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class TLMessage(TLObject):
|
class TLMessage(TLObject):
|
||||||
"""
|
"""
|
||||||
|
@ -48,11 +51,17 @@ class TLMessage(TLObject):
|
||||||
if not out:
|
if not out:
|
||||||
self._body = struct.pack('<qi', msg_id, seq_no)
|
self._body = struct.pack('<qi', msg_id, seq_no)
|
||||||
else:
|
else:
|
||||||
|
try:
|
||||||
if self.after_id is None:
|
if self.after_id is None:
|
||||||
body = GzipPacked.gzip_if_smaller(self.obj)
|
body = GzipPacked.gzip_if_smaller(self.obj)
|
||||||
else:
|
else:
|
||||||
body = GzipPacked.gzip_if_smaller(
|
body = GzipPacked.gzip_if_smaller(
|
||||||
InvokeAfterMsgRequest(self.after_id, self.obj))
|
InvokeAfterMsgRequest(self.after_id, self.obj))
|
||||||
|
except Exception:
|
||||||
|
# struct.pack doesn't give a lot of information about
|
||||||
|
# why it may fail so log the exception AND the object
|
||||||
|
__log__.exception('Failed to pack %s', self.obj)
|
||||||
|
raise
|
||||||
|
|
||||||
self._body = struct.pack('<qii', msg_id, seq_no, len(body)) + body
|
self._body = struct.pack('<qii', msg_id, seq_no, len(body)) + body
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user