CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CSCDQM_Exception.h
Go to the documentation of this file.
1 /*
2  * =====================================================================================
3  *
4  * Filename: CSCDQM_Exception.h
5  *
6  * Description: Custom Exception
7  *
8  * Version: 1.0
9  * Created: 11/14/2008 11:51:31 AM
10  * Revision: none
11  * Compiler: gcc
12  *
13  * Author: Valdas Rapsevicius (VR), valdas.rapsevicius@cern.ch
14  * Company: CERN, CH
15  *
16  * =====================================================================================
17  */
18 
19 #ifndef CSCDQM_Exception_H
20 #define CSCDQM_Exception_H
21 
22 #include <string>
23 #include <exception>
24 
25 #include <xercesc/sax/ErrorHandler.hpp>
26 #include <xercesc/sax/SAXParseException.hpp>
27 
28 #include "CSCDQM_Logger.h"
29 
30 namespace cscdqm {
31 
37  class Exception: public std::exception {
38  private:
39 
41 
42  public:
43 
44  Exception(const std::string& message) throw() {
45  this->message = message;
46  }
47 
48  virtual ~Exception() throw() { }
49 
50  virtual const char* what() const throw() {
51  return message.c_str();
52  }
53 
54  };
55 
61  class XMLFileErrorHandler : public XERCES_CPP_NAMESPACE::ErrorHandler {
62 
63  public:
64 
65  void warning(const XERCES_CPP_NAMESPACE::SAXParseException& exc) {
66  char* message = XERCES_CPP_NAMESPACE::XMLString::transcode(exc.getMessage());
67  LOG_WARN << "File: " << message << ". line: " << exc.getLineNumber() << " col: " << exc.getColumnNumber();
69  }
70 
71  void error(const XERCES_CPP_NAMESPACE::SAXParseException& exc) {
72  this->fatalError(exc);
73  }
74 
75  void fatalError(const XERCES_CPP_NAMESPACE::SAXParseException& exc) {
76  char* message = XERCES_CPP_NAMESPACE::XMLString::transcode(exc.getMessage());
77  LOG_COUT << "File: " << message << ". line: " << exc.getLineNumber() << " col: " << exc.getColumnNumber();
78  throw Exception(message);
79  }
80 
81  void resetErrors () { }
82 
83  };
84 
85 }
86 
87 #endif
Application level Exception that is used to cut-off application execution in various cases...
void warning(const XERCES_CPP_NAMESPACE::SAXParseException &exc)
virtual const char * what() const
XMLCh * transcode(const T &fInput)
Exception(const std::string &message)
#define LOG_WARN
Definition: CSCDQM_Logger.h:42
void fatalError(const XERCES_CPP_NAMESPACE::SAXParseException &exc)
void error(const XERCES_CPP_NAMESPACE::SAXParseException &exc)
Takes care of errors and warnings while parsing XML files file in XML format.
#define LOG_COUT
Definition: CSCDQM_Logger.h:44