NCBI C++ ToolKit
html_exception.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef HTML___EXCEPTION__HPP
2 #define HTML___EXCEPTION__HPP
3 
4 /* $Id: html_exception.hpp 84663 2018-11-27 18:22:00Z ucko $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Author: Andrei Gourianov
30  *
31  */
32 
33 /// @file html_exception.hpp
34 /// HTML library exceptions.
35 ///
36 /// Defines class to generate exceptions from the HTML library.
37 
38 
39 #include <corelib/ncbiexpt.hpp>
40 
41 
42 /** @addtogroup HTMLexpt
43  *
44  * @{
45  */
46 
47 
49 
50 
51 /////////////////////////////////////////////////////////////////////////////
52 ///
53 /// CHTMLException --
54 ///
55 /// Define an extended exception class based on the CException
56 ///
57 /// CHTMLException inherits its basic functionality from CException and
58 /// defines additional reporting capabilities.
59 
62 {
63 public:
64  enum EErrCode {
74  eUnknown
75  };
76 
77  virtual const char* GetErrCodeString(void) const override
78  {
79  switch ( GetErrCode() ) {
80  case eNullPtr: return "eNullPtr";
81  case eWrite: return "eWrite";
82  case eTextUnclosedTag: return "eTextUnclosedTag";
83  case eTableCellUse: return "eTableCellUse";
84  case eTableCellType: return "eTableCellType";
85  case eTemplateAccess: return "eTemplateAccess";
86  case eTemplateTooBig: return "eTemplateTooBig";
87  case eEndlessRecursion: return "eEndlessRecursion";
88  case eUnknown: return "eUnknown";
89  case eNotFound: return "eNotFound";
90  default: return CException::GetErrCodeString();
91  }
92  }
93 
94  /// Constructor.
96  const CException* prev_exception, EErrCode err_code,
97  const string& message,
98  EDiagSev severity = eDiag_Error)
99  : CException(info, prev_exception, CException::eInvalid, message)
101 
102 public:
103  /// Add node name to tracing path.
104  virtual void AddTraceInfo(const string& node_name);
105 
106  /// Report node trace into the "out" stream.
107  virtual void ReportExtra(ostream& out) const override;
108 
109 protected:
110  /// Helper method for copying exception data.
111  virtual void x_Assign(const CException& src) override;
112 
113 protected:
114  list<string> m_Trace; ///< Node trace list.
115 };
116 
117 
119 
120 
121 /* @} */
122 
123 #endif /* HTML___EXCEPTION__HPP */
Incapsulate compile time information such as __FILE__, __LINE__, NCBI_MODULE, current function.
Definition: ncbidiag.hpp:65
CHTMLException –.
std::ofstream out("events_result.xml")
main entry point for tests
EDiagSev
Severity level for the posted diagnostics.
Definition: ncbidiag.hpp:650
@ eDiag_Error
Error message.
Definition: ncbidiag.hpp:653
virtual void ReportExtra(ostream &out) const
Report "non-standard" attributes.
Definition: ncbiexpt.cpp:428
TErrCode GetErrCode(void) const
Get error code.
Definition: ncbiexpt.cpp:453
virtual void x_Assign(const CException &src)
Helper method for copying exception data.
Definition: ncbiexpt.cpp:536
#define NCBI_EXCEPTION_DEFAULT_IMPLEMENTATION(exception_class, base_class)
Helper macro for default exception implementation.
Definition: ncbiexpt.hpp:1300
virtual const char * GetErrCodeString(void) const
Get error code interpreted as text.
Definition: ncbiexpt.cpp:444
#define EXCEPTION_VIRTUAL_BASE
Do not use virtual base classes in exception declaration at all, because in this case derived class s...
Definition: ncbiexpt.hpp:1388
@ eUnknown
Unknown exception.
Definition: ncbiexpt.hpp:887
virtual const char * GetErrCodeString(void) const override
list< string > m_Trace
Node trace list.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define NCBI_XHTML_EXPORT
Definition: ncbi_export.h:1139
static MDB_envinfo info
Definition: mdb_load.c:37
Defines NCBI C++ exception handling.
@ eNotFound
Not found.
Modified on Wed Sep 04 15:01:21 2024 by modify_doxy.py rev. 669887