Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef CSCDQM_Exception_H
00020 #define CSCDQM_Exception_H
00021
00022 #include <string>
00023 #include <exception>
00024
00025 #include <xercesc/sax/ErrorHandler.hpp>
00026 #include <xercesc/sax/SAXParseException.hpp>
00027
00028 #include "CSCDQM_Logger.h"
00029
00030 namespace cscdqm {
00031
00037 class Exception: public std::exception {
00038 private:
00039
00040 std::string message;
00041
00042 public:
00043
00044 Exception(const std::string& message) throw() {
00045 this->message = message;
00046 }
00047
00048 virtual ~Exception() throw() { }
00049
00050 virtual const char* what() const throw() {
00051 return message.c_str();
00052 }
00053
00054 };
00055
00061 class XMLFileErrorHandler : public XERCES_CPP_NAMESPACE::ErrorHandler {
00062
00063 public:
00064
00065 void warning(const XERCES_CPP_NAMESPACE::SAXParseException& exc) {
00066 char* message = XERCES_CPP_NAMESPACE::XMLString::transcode(exc.getMessage());
00067 LOG_WARN << "File: " << message << ". line: " << exc.getLineNumber() << " col: " << exc.getColumnNumber();
00068 XERCES_CPP_NAMESPACE::XMLString::release(&message);
00069 }
00070
00071 void error(const XERCES_CPP_NAMESPACE::SAXParseException& exc) {
00072 this->fatalError(exc);
00073 }
00074
00075 void fatalError(const XERCES_CPP_NAMESPACE::SAXParseException& exc) {
00076 char* message = XERCES_CPP_NAMESPACE::XMLString::transcode(exc.getMessage());
00077 LOG_COUT << "File: " << message << ". line: " << exc.getLineNumber() << " col: " << exc.getColumnNumber();
00078 throw Exception(message);
00079 }
00080
00081 void resetErrors () { }
00082
00083 };
00084
00085 }
00086
00087 #endif