I'm writing a small library to open an xml. If reading top level xml element fails, the library throws an exception.
However, if reading one of the minor, lower level xml elemetns fail, I currently throw the exception to stop the constructor, but then catch it and do nothing with it, since the error may not be critical.
I need a way to tell the main program that something did happen.
I can think of two ways of making that happen. One is to store offending data into some structure and make it accessible to the program which calls the library. This is my first choice, bit I'm open to suggestion.
Another is to pass some kind of stream to which the library will write errors to.
The problem here is that I either have to pick between library not being dependent in the stream I pass and making sure that error output style matches the one of the main program.
Is there some OO way this is normally done? Is there a better way?
EDIT: I'm not writing an xml reader, I'm using the one that comes with .NET. The data I get from XML may or may not be okay for my use, that is the bit that I'm dealing with.