summaryrefslogtreecommitdiff
path: root/cpp/src/Freeze/ErrorHandler.h
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/Freeze/ErrorHandler.h')
-rw-r--r--cpp/src/Freeze/ErrorHandler.h56
1 files changed, 56 insertions, 0 deletions
diff --git a/cpp/src/Freeze/ErrorHandler.h b/cpp/src/Freeze/ErrorHandler.h
new file mode 100644
index 00000000000..5f169670029
--- /dev/null
+++ b/cpp/src/Freeze/ErrorHandler.h
@@ -0,0 +1,56 @@
+#ifndef ERROR_HANDLER_H
+#define ERROR_HANDLER_H
+
+#include <sax/ErrorHandler.hpp>
+#include <sax/SAXParseException.hpp>
+
+#include <Freeze/Print.h>
+
+class DOMTreeErrorReporter : public ErrorHandler
+{
+public:
+ DOMTreeErrorReporter() :
+ _sawErrors(false)
+ {
+ }
+
+ void
+ warning(const SAXParseException& toCatch)
+ {
+ ::std::cerr << "Warning at file \"" << DOMString(toCatch.getSystemId())
+ << "\", line " << toCatch.getLineNumber()
+ << ", column " << toCatch.getColumnNumber()
+ << "\n Message: " << DOMString(toCatch.getMessage()) << ::std::endl;
+ }
+
+ void
+ error(const SAXParseException& toCatch)
+ {
+ _sawErrors = true;
+ ::std::cerr << "Error at file \"" << DOMString(toCatch.getSystemId())
+ << "\", line " << toCatch.getLineNumber()
+ << ", column " << toCatch.getColumnNumber()
+ << "\n Message: " << DOMString(toCatch.getMessage()) << ::std::endl;
+
+ }
+
+ void
+ fatalError(const SAXParseException& toCatch)
+ {
+ _sawErrors = true;
+ ::std::cerr << "Fatal at file \"" << DOMString(toCatch.getSystemId())
+ << "\", line " << toCatch.getLineNumber()
+ << ", column " << toCatch.getColumnNumber()
+ << "\n Message: " << DOMString(toCatch.getMessage()) << ::std::endl;
+ }
+
+ void resetErrors()
+ {
+ }
+
+ bool getSawErrors() const { return _sawErrors; }
+
+ bool _sawErrors;
+};
+
+#endif