add length info to exceptions complaining about length

This commit is contained in:
Brian S. Stephan 2023-06-28 14:37:36 -05:00
parent 39fa558741
commit 1345e8b18d
Signed by: bss
GPG Key ID: 3DE06D3180895FCB
1 changed files with 3 additions and 2 deletions

View File

@ -64,7 +64,7 @@ def get_config_footer(content: bytes) -> tuple[int, int, str]:
# last 12 bytes are the footer
logger.debug("length of content to look for footer in: %s", len(content))
if len(content) < FOOTER_SIZE:
raise ConfigLengthError("provided content is not large enough to have a config footer!")
raise ConfigLengthError(f"provided content ({len(content)} bytes) is not large enough to have a config footer!")
footer = content[-FOOTER_SIZE:]
logger.debug("suspected footer magic: %s", footer[-4:])
@ -77,7 +77,8 @@ def get_config_footer(content: bytes) -> tuple[int, int, str]:
# more sanity checks
if len(content) < config_size + FOOTER_SIZE:
raise ConfigLengthError("provided content is not large enough according to the config footer!")
raise ConfigLengthError(f"provided content ({len(content)} bytes) is not large enough according to the "
f"config footer!")
content_crc = binascii.crc32(content[-(config_size + 12):-12])
if config_crc != content_crc: