Nicer error when failing to decode CFI

This commit is contained in:
Kovid Goyal 2023-04-19 22:54:34 +05:30
parent cc89ccb265
commit b63ca39143
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -322,6 +322,7 @@ def decode(cfi, doc):
error = None error = None
node = doc node = doc
orig_cfi = cfi
while cfi.length > 0 and not error: while cfi.length > 0 and not error:
r = cfi.match(simple_node_regex) r = cfi.match(simple_node_regex)
if r: # Path step if r: # Path step
@ -335,7 +336,7 @@ def decode(cfi, doc):
cfi = cfi.substr(r[0].length) cfi = cfi.substr(r[0].length)
else: else:
if target: if target:
error = "No matching child found for CFI: " + cfi error = f"No matching child found for CFI: {orig_cfi} leftover: {cfi}"
break break
else: else:
cfi = cfi.substr(r[0].length) cfi = cfi.substr(r[0].length)