mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-08 04:52:30 +00:00
Make BufferError message more useful
This commit is contained in:
@@ -23,6 +23,7 @@ class BinaryReader:
|
||||
'Either bytes or a stream must be provided')
|
||||
|
||||
self.reader = BufferedReader(self.stream)
|
||||
self._last = None # Should come in handy to spot -404 errors
|
||||
|
||||
# region Reading
|
||||
|
||||
@@ -57,8 +58,12 @@ class BinaryReader:
|
||||
"""Read the given amount of bytes"""
|
||||
result = self.reader.read(length)
|
||||
if len(result) != length:
|
||||
raise BufferError('No more data left to read')
|
||||
raise BufferError(
|
||||
'No more data left to read (need {}, got {}: {}); last read {}'
|
||||
.format(length, len(result), repr(result), repr(self._last))
|
||||
)
|
||||
|
||||
self._last = result
|
||||
return result
|
||||
|
||||
def get_bytes(self):
|
||||
|
Reference in New Issue
Block a user