A library function parses a file and returns an object. If a parser encounters unknown data, missing values etc., it shouldn’t throw an exception and stop parsing (because this is not fatal), but there should be a way to pass information about these things to a caller (so that warnings can be displayed in the UI, for example). How can these warning be returned? I’m thinking of passing a callback function/object into the library, are there any other possible solutions?
Share
I would have a collection of errors easily accessible on the parser, something like this:
Or whatever error type you wanted of course, something with more detail maybe.
Code calling your library would look something like this: