otsdaq  v1_01_02
 All Classes Namespaces Functions
DOMTreeErrorReporter.cc
1 #include "otsdaq-core/XmlUtilities/DOMTreeErrorReporter.h"
2 #include "otsdaq-core/MessageFacility/MessageFacility.h"
3 #include "otsdaq-core/Macros/CoutHeaderMacros.h"
4 
5 #include <iostream>
6 #include <sstream>
7 #include <xercesc/util/XMLString.hpp>
8 
9 using namespace ots;
10 
11 #undef __MOUT_HDR__
12 #define __MOUT_HDR__ "DOMTreeErrorReporter"
13 
14 //==============================================================================
15 DOMTreeErrorReporter::DOMTreeErrorReporter()
16 {}
17 
18 //==============================================================================
19 DOMTreeErrorReporter::~DOMTreeErrorReporter()
20 {}
21 
22 //==============================================================================
23 void DOMTreeErrorReporter::warning(const xercesc::SAXParseException& ex)
24 {
25  __MOUT__ << "Warning!" << std::endl;
26  throw std::runtime_error(reportParseException(ex));
27 }
28 
29 //==============================================================================
30 void DOMTreeErrorReporter::error(const xercesc::SAXParseException& ex)
31 {
32  __MOUT__ << "Error!" << std::endl;
33  throw std::runtime_error(reportParseException(ex));
34 }
35 
36 //==============================================================================
37 void DOMTreeErrorReporter::fatalError(const xercesc::SAXParseException& ex)
38 {
39  __MOUT__ << "Fatal Error!" << std::endl;
40  throw std::runtime_error(reportParseException(ex));
41 }
42 
43 //==============================================================================
44 void DOMTreeErrorReporter::resetErrors()
45 {}
46 
47 //==============================================================================
48 std::string DOMTreeErrorReporter::reportParseException(const xercesc::SAXParseException& exception)
49 {
50  __SS__ << "\n"
51  << "\tIn file \""
52  << xercesc::XMLString::transcode(exception.getSystemId())
53  << "\", line "
54  << exception.getLineNumber()
55  << ", column "
56  << exception.getColumnNumber()
57  << std::endl
58  << "\tMessage: "
59  << xercesc::XMLString::transcode(exception.getMessage())
60  //<< " (check against xsd file)" //RAR commented, has no meaning to me or users..
61  << "\n\n" ;
62  __MOUT__ << "\n" << ss.str() << std::endl;
63  return ss.str();
64 }