CMS 3D CMS Logo

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:
40 
41  public:
42  Exception(const std::string& message) throw() { this->message = message; }
43 
44  ~Exception() throw() override {}
45 
46  const char* what() const throw() override { return message.c_str(); }
47  };
48 
54  class XMLFileErrorHandler : public XERCES_CPP_NAMESPACE::ErrorHandler {
55  public:
56  void warning(const XERCES_CPP_NAMESPACE::SAXParseException& exc) override {
57  char* message = XERCES_CPP_NAMESPACE::XMLString::transcode(exc.getMessage());
58  LOG_WARN << "File: " << message << ". line: " << exc.getLineNumber() << " col: " << exc.getColumnNumber();
60  }
61 
62  void error(const XERCES_CPP_NAMESPACE::SAXParseException& exc) override { this->fatalError(exc); }
63 
64  void fatalError(const XERCES_CPP_NAMESPACE::SAXParseException& exc) override {
65  char* message = XERCES_CPP_NAMESPACE::XMLString::transcode(exc.getMessage());
66  LOG_COUT << "File: " << message << ". line: " << exc.getLineNumber() << " col: " << exc.getColumnNumber();
67  throw Exception(message);
68  }
69 
70  void resetErrors() override {}
71  };
72 
73 } // namespace cscdqm
74 
75 #endif
CSCDQM_Logger.h
cscdqm::Exception::Exception
Exception(const std::string &message)
Definition: CSCDQM_Exception.h:42
cscdqm::XMLFileErrorHandler::resetErrors
void resetErrors() override
Definition: CSCDQM_Exception.h:70
LOG_COUT
#define LOG_COUT
Definition: CSCDQM_Logger.h:43
cscdqm::XMLFileErrorHandler::fatalError
void fatalError(const XERCES_CPP_NAMESPACE::SAXParseException &exc) override
Definition: CSCDQM_Exception.h:64
cscdqm::Exception::what
const char * what() const override
Definition: CSCDQM_Exception.h:46
cscdqm::XMLFileErrorHandler
Takes care of errors and warnings while parsing XML files file in XML format.
Definition: CSCDQM_Exception.h:54
cscdqm::Exception::message
std::string message
Definition: CSCDQM_Exception.h:39
cppFunctionSkipper.exception
exception
Definition: cppFunctionSkipper.py:10
fetchall_from_DQM_v2.release
release
Definition: fetchall_from_DQM_v2.py:92
cscdqm
Definition: CSCDQM_DCSBase.h:29
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cscdqm::XMLFileErrorHandler::warning
void warning(const XERCES_CPP_NAMESPACE::SAXParseException &exc) override
Definition: CSCDQM_Exception.h:56
Exception
Definition: hltDiff.cc:245
cscdqm::Exception
Application level Exception that is used to cut-off application execution in various cases.
Definition: CSCDQM_Exception.h:37
ALCARECOPromptCalibProdSiPixelAli0T_cff.throw
throw
Definition: ALCARECOPromptCalibProdSiPixelAli0T_cff.py:9
LOG_WARN
#define LOG_WARN
Definition: CSCDQM_Logger.h:41
cscdqm::Exception::~Exception
~Exception() override
Definition: CSCDQM_Exception.h:44
cscdqm::XMLFileErrorHandler::error
void error(const XERCES_CPP_NAMESPACE::SAXParseException &exc) override
Definition: CSCDQM_Exception.h:62