I have read lots of stuff on error handling in Rust, and most of it seems to be focused around returning a
Result object. This is fine, of course, but it does not seem very pluggable to me.
I am writing a parser for a piece of XML, and I want the parser to check for errors. But I need it to do different things under different circumstances: parse to the end, summarize all the errors; stop at the first error; and so forth.
My thought was to pass in a function and use this to do call-backs: like an error handler object in java or equivalent. But I’ve not see this done elsewhere and wonder if I am missing something more idiomatic.