ANNA Suite  2020b
Multipurpose development suite for Telco applications
Exception.hpp
Go to the documentation of this file.
1 // ANNA - Anna is Not Nothingness Anymore //
2 // //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
4 // //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
7 
8 
9 #ifndef anna_core_Exception_hpp
10 #define anna_core_Exception_hpp
11 
12 #include <string>
13 #include <exception>
14 
15 namespace anna {
16 
20 class Exception : public std::exception {
21 public:
26  struct Mode { enum _v { Ignore, Throw, Trace }; };
27 
34  Exception(const char* text, const char* fromFile, const int fromLine);
35 
41  Exception(const Exception& other);
42 
46  virtual ~Exception() {;}
47 
48  // Accesores
52  const std::string& getText() const { return m_text;}
53 
58  const char* getFromFile() const { return m_fromFile.c_str(); }
59 
64  int getFromLine() const { return m_fromLine; }
65 
72  void setErrorCode(const int errorCode) { m_errorCode = errorCode; }
73 
77  int getErrorCode() const { return m_errorCode; }
78 
79  // Operadores
87  Exception& operator = (const Exception& right) ;
88 
89  // Metodos
96  std::string asString() const ;
97 
106  const char* what() const noexcept { return asString().c_str(); } // JASC, 23/9/2003 antes dAata() ( no tenia el trailing null )
107 
114  void trace() const ;
115 
116 protected:
117  Exception(const char* text, const char* name, const char* fromFile, const int fromLine);
118 
124  void setText(const char* text) { m_text = text; }
125 
131  void setText(const std::string& text) { m_text = text; }
132 
133 private:
134  std::string m_text;
135  std::string m_name;
136  std::string m_fromFile;
137  int m_fromLine;
138  int m_errorCode;
139 };
140 
141 } //namespace anna
142 
143 #endif
void setText(const char *text)
Definition: Exception.hpp:124
Definition: Exception.hpp:26
Definition: Exception.hpp:26
virtual ~Exception()
Definition: Exception.hpp:46
Definition: Exception.hpp:26
const char * getFromFile() const
Definition: Exception.hpp:58
int getErrorCode() const
Definition: Exception.hpp:77
Exception & operator=(const Exception &right)
_v
Definition: Exception.hpp:26
Definition: Exception.hpp:26
void trace() const
Definition: Exception.hpp:20
std::string asString() const
const std::string & getText() const
Definition: Exception.hpp:52
void setText(const std::string &text)
Definition: Exception.hpp:131
Definition: app.hpp:12
Exception(const char *text, const char *fromFile, const int fromLine)
const char * what() const noexcept
Definition: Exception.hpp:106
int getFromLine() const
Definition: Exception.hpp:64
void setErrorCode(const int errorCode)
Definition: Exception.hpp:72