Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-fatal non-exception based error handling should be provided #10

Open
clevijoki opened this issue Apr 2, 2018 · 1 comment
Open

Comments

@clevijoki
Copy link

Using exceptions is the only way to parse xml and have it not crash the program on a formatting error. So if we can't use exceptions, rapidxml becomes unusable if you want to gracefully handle bad formatting.

The usage of a globally linked error handler is also problematic, multiple places in the code using rapidxml w/o exceptions will cause linking problems, and it requires workarounds to wrap the #include <rapidxml.hpp> in a namespace so multiple error handlers can be provided.

Ideally a function pointer object could be provided to rapidxml that would allow us to do our own exception handling, that could contain user data where we can map to our own local information, so the filename and such can be printed in a thread-safe manner.

@dwd
Copy link
Owner

dwd commented Apr 3, 2018

So what I'm thinking is we have a rapidxml::xml_document<>::set_error_handler(...) function which takes a std::function<...>(...) (types to be figured out later).

Then the code can call that instead of the nasty macro.

I'll need to fiddle about a bit to try to guess what will work in the C++03 that rapidxml targets; I think I've avoided introducing C++11 so far.

Would that work for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants