CGMES_3_0_0
Loading...
Searching...
No Matches
SAXErrorHandler.hpp
1#ifndef SAX_ERRORHANDLER_HPP
2#define SAX_ERRORHANDLER_HPP
3
4#include <SAX/ErrorHandler.hpp>
5#include <SAX/Locator.hpp>
6#include <SAX/ArabicaConfig.hpp>
7#include <iostream>
8#include <string>
9
10class SAXErrorHandler : public Arabica::SAX::ErrorHandler<std::string>
11{
12private:
13 std::string saxParser;
14
15public:
16 SAXErrorHandler()
17 {
18#ifdef ARABICA_USE_LIBXML2
19 saxParser = "Libxml2";
20#elif defined(ARABICA_USE_MSXML)
21 saxParser = "MSXML";
22#else
23 saxParser = "SAX Parser";
24#endif
25 };
26
27 ~SAXErrorHandler(){};
28
29 void warning(const SAXParseExceptionT& exception){};
30
31 void error(const SAXParseExceptionT& exception)
32 {
33 std::cerr << saxParser << " encountered an Error:\n" << exception.what() << std::endl;
34 throw(exception); // SAXParseException is an std::runtime_error
35 };
36
37 void fatalError(const SAXParseExceptionT& exception)
38 {
39 std::cerr << saxParser << " encountered a Fatal Error:\n" << exception.what() << std::endl;
40 throw(exception); // SAXParseException is an std::runtime_error
41 };
42};
43
44#endif //SAX_ERRORHANDLER_HPP