How to properly debug Deku input data?
peterdk opened this issue · comments
I am new to Deku, and have a existing library that I am modifying, since it fails to parse a small set of input files (edge cases, since many thousands succeed).
I am wondering, how can I get some context from Deku, when it fails to parse a certain struct? I for example would want to know the position of the parser in the input Vec<u8>
, and preferably the surrounding bytes.
Is this info available somehow?
I now get:
Foo::try_from(input).unwrap() => Error: Parse("Could not match enum variant id = 33 on enum `Bar`")
So I do know the input Bar value is 33, but there is no context, and I am having a very hard time debugging. There are a lot of elements that are used in this lib with Deku, also Vec's of these elements. So it's not straightforward and I'm wondering if I should just rewrite this library to manual parsing, so I at least get more insight in the parsing process and can actually debug.
Hopefully I am wrong and I can use Deku, it seems a nice library.
And is for example the partial succesful output of the parser available when it fails? So the parsed structures until point of failure?
Deku does have a logging feature which can be enabled to get tracing output, this may be helpful if you're trying to debug, there are some instructions here:
Lines 296 to 316 in c905a64
At the moment there is not a good facility for getting feedback in the form of errors on partial successful output or indexes into the input. This is a welcome improvement to the library.
Thanks, that's at least a entry point into understanding the issues I face. I'll try it out.
Let us know if that works for you or if you need more help, closing for now