00001 #include "otsdaq-core/XmlUtilities/DOMTreeErrorReporter.h"
00002 #include "otsdaq-core/MessageFacility/MessageFacility.h"
00003 #include "otsdaq-core/Macros/CoutMacros.h"
00004
00005 #include <iostream>
00006 #include <sstream>
00007 #include <xercesc/util/XMLString.hpp>
00008
00009 using namespace ots;
00010
00011 #undef __COUT_HDR__
00012 #define __COUT_HDR__ "DOMTreeErrorReporter"
00013
00014
00015 DOMTreeErrorReporter::DOMTreeErrorReporter()
00016 {}
00017
00018
00019 DOMTreeErrorReporter::~DOMTreeErrorReporter()
00020 {}
00021
00022
00023 void DOMTreeErrorReporter::warning(const xercesc::SAXParseException& ex)
00024 {
00025 __COUT__ << "Warning!" << std::endl;
00026 throw std::runtime_error(reportParseException(ex));
00027 }
00028
00029
00030 void DOMTreeErrorReporter::error(const xercesc::SAXParseException& ex)
00031 {
00032 __COUT__ << "Error!" << std::endl;
00033 throw std::runtime_error(reportParseException(ex));
00034 }
00035
00036
00037 void DOMTreeErrorReporter::fatalError(const xercesc::SAXParseException& ex)
00038 {
00039 __COUT__ << "Fatal Error!" << std::endl;
00040 throw std::runtime_error(reportParseException(ex));
00041 }
00042
00043
00044 void DOMTreeErrorReporter::resetErrors()
00045 {}
00046
00047
00048 std::string DOMTreeErrorReporter::reportParseException(const xercesc::SAXParseException& exception)
00049 {
00050 __SS__ << "\n"
00051 << "\tIn file \""
00052 << xercesc::XMLString::transcode(exception.getSystemId())
00053 << "\", line "
00054 << exception.getLineNumber()
00055 << ", column "
00056 << exception.getColumnNumber()
00057 << std::endl
00058 << "\tMessage: "
00059 << xercesc::XMLString::transcode(exception.getMessage())
00060
00061 << "\n\n" ;
00062 __COUT__ << "\n" << ss.str() << std::endl;
00063 return ss.str();
00064 }