exception-abstract.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2010,
3  * François Bleibel,
4  * Olivier Stasse,
5  *
6  * CNRS/AIST
7  *
8  */
9 
10 #include <sot/core/debug.hh>
12 
13 using namespace std;
14 using namespace dynamicgraph::sot;
15 
16 /* ------------------------------------------------------------------------- */
17 /* --- CONSTRUCTORS -------------------------------------------------------- */
18 /* ------------------------------------------------------------------------- */
19 
20 const std::string ExceptionAbstract::EXCEPTION_NAME = "Abstract";
21 
22 ExceptionAbstract::ExceptionAbstract(const int &_code, const string &_msg)
23  : code(_code),
24  message(_msg)
25 
26 {
27  return;
28 }
29 
30 /* ------------------------------------------------------------------------ */
31 /* --- ACCESSORS ---------------------------------------------------------- */
32 /* ------------------------------------------------------------------------ */
33 
34 const char *ExceptionAbstract::getMessage(void) {
35  return (this->message).c_str();
36 }
37 
39  return this->message;
40 }
41 
42 int ExceptionAbstract::getCode(void) { return this->code; }
43 
44 const char *ExceptionAbstract::what() const throw() { return message.c_str(); }
45 
46 /* ------------------------------------------------------------------------- */
47 /* --- MODIFIORS ----------------------------------------------------------- */
48 /* ------------------------------------------------------------------------- */
49 #ifdef SOT_EXCEPTION_PASSING_PARAM
50 
52  sotDEBUGIN(25);
53  if (p.pointersSet) {
54  strncpy(function, p.functionPTR, BUFFER_SIZE);
55  strncpy(file, p.filePTR, BUFFER_SIZE);
56  line = p.line;
57  pointersSet = false;
58  set = true;
59  } else
60  set = false;
61  sotDEBUGOUT(25);
62  return *this;
63 }
64 ExceptionAbstract::Param::Param(const int &_line, const char *_function,
65  const char *_file)
66  : functionPTR(_function), line(_line), filePTR(_file), pointersSet(true) {
67  sotDEBUGINOUT(25);
68 }
69 #endif // #ifdef SOT_EXCEPTION_PASSING_PARAM
70 
71 /* ------------------------------------------------------------------------- */
72 /* --- OP << --------------------------------------------------------------- */
73 /* ------------------------------------------------------------------------- */
74 
75 namespace dynamicgraph {
76 namespace sot {
77 ostream &operator<<(ostream &os, const ExceptionAbstract &error) {
78  os << error.getExceptionName() << "Error [#" << error.code
79  << "]: " << error.message << endl;
80 
81 #ifdef SOT_EXCEPTION_PASSING_PARAM
82  if (error.p.set)
83  os << "Thrown from " << error.p.file << ": " << error.p.function << " (#"
84  << error.p.line << ")" << endl;
85 #endif // #ifdef SOT_EXCEPTION_PASSING_PARAM
86  return os;
87 }
88 } // namespace sot
89 } // namespace dynamicgraph
90 
94 /*
95  * Local variables:
96  * c-basic-offset: 2
97  * End:
98  */
const std::string & getStringMessage() const
Param & initCopy(const Param &p)
#define sotDEBUGOUT(level)
Definition: debug.hh:212
#define sotDEBUGIN(level)
Definition: debug.hh:211
#define sotDEBUGINOUT(level)
Definition: debug.hh:213
const char * getMessage() const
virtual const std::string & getExceptionName() const
SOT_CORE_EXPORT std::ostream & operator<<(std::ostream &os, const VectorMultiBound &v)
virtual const char * what() const
int line
p


sot-core
Author(s): Olivier Stasse, ostasse@laas.fr
autogenerated on Wed Jun 21 2023 02:51:26