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;
16 
17 /* ------------------------------------------------------------------------- */
18 /* --- CONSTRUCTORS -------------------------------------------------------- */
19 /* ------------------------------------------------------------------------- */
20 
21 const std::string ExceptionAbstract::EXCEPTION_NAME = "Abstract";
22 
23 ExceptionAbstract::ExceptionAbstract(const size_type &_code, const string &_msg)
24  : code(_code),
25  message(_msg)
26 
27 {
28  return;
29 }
30 
31 /* ------------------------------------------------------------------------ */
32 /* --- ACCESSORS ---------------------------------------------------------- */
33 /* ------------------------------------------------------------------------ */
34 
35 const char *ExceptionAbstract::getMessage(void) {
36  return (this->message).c_str();
37 }
38 
40  return this->message;
41 }
42 
43 size_type ExceptionAbstract::getCode(void) { return this->code; }
44 
45 const char *ExceptionAbstract::what() const throw() { return message.c_str(); }
46 
47 /* ------------------------------------------------------------------------- */
48 /* --- MODIFIORS ----------------------------------------------------------- */
49 /* ------------------------------------------------------------------------- */
50 #ifdef SOT_EXCEPTION_PASSING_PARAM
51 
53  sotDEBUGIN(25);
54  if (p.pointersSet) {
55  strncpy(function, p.functionPTR, BUFFER_SIZE);
56  strncpy(file, p.filePTR, BUFFER_SIZE);
57  line = p.line;
58  pointersSet = false;
59  set = true;
60  } else
61  set = false;
62  sotDEBUGOUT(25);
63  return *this;
64 }
65 ExceptionAbstract::Param::Param(const size_type &_line, const char *_function,
66  const char *_file)
67  : functionPTR(_function), line(_line), filePTR(_file), pointersSet(true) {
68  sotDEBUGINOUT(25);
69 }
70 #endif // #ifdef SOT_EXCEPTION_PASSING_PARAM
71 
72 /* ------------------------------------------------------------------------- */
73 /* --- OP << --------------------------------------------------------------- */
74 /* ------------------------------------------------------------------------- */
75 
76 namespace dynamicgraph {
77 namespace sot {
78 ostream &operator<<(ostream &os, const ExceptionAbstract &error) {
79  os << error.getExceptionName() << "Error [#" << error.code
80  << "]: " << error.message << endl;
81 
82 #ifdef SOT_EXCEPTION_PASSING_PARAM
83  if (error.p.set)
84  os << "Thrown from " << error.p.file << ": " << error.p.function << " (#"
85  << error.p.line << ")" << endl;
86 #endif // #ifdef SOT_EXCEPTION_PASSING_PARAM
87  return os;
88 }
89 } // namespace sot
90 } // namespace dynamicgraph
91 
95 /*
96  * Local variables:
97  * c-basic-offset: 2
98  * End:
99  */
dynamicgraph::ExceptionAbstract::getStringMessage
const std::string & getStringMessage() const
dynamicgraph::ExceptionAbstract::Param
dynamicgraph
size_type
dynamicgraph::size_type size_type
Definition: exception-abstract.cpp:15
dynamicgraph::ExceptionAbstract::Param::BUFFER_SIZE
static const int BUFFER_SIZE
dynamicgraph::ExceptionAbstract::code
int code
debug.hh
p
p
dynamicgraph::ExceptionAbstract::Param::file
char file[BUFFER_SIZE]
sotDEBUGOUT
#define sotDEBUGOUT(level)
Definition: debug.hh:215
dynamicgraph::ExceptionAbstract::Param::set
bool set
dynamicgraph::ExceptionAbstract::Param::line
int line
sotDEBUGINOUT
#define sotDEBUGINOUT(level)
Definition: debug.hh:216
dynamicgraph::ExceptionAbstract
sotDEBUGIN
#define sotDEBUGIN(level)
Definition: debug.hh:214
dynamicgraph::ExceptionAbstract::getCode
int getCode() const
dynamicgraph::size_type
Matrix::Index size_type
dynamicgraph::ExceptionAbstract::Param::pointersSet
bool pointersSet
dynamicgraph::sot::operator<<
SOT_CORE_EXPORT std::ostream & operator<<(std::ostream &os, const VectorMultiBound &v)
Definition: multi-bound.cpp:228
dynamicgraph::ExceptionAbstract::message
std::string message
dynamicgraph::sot
exception-abstract.hh
dynamicgraph::ExceptionAbstract::Param::initCopy
Param & initCopy(const Param &p)
dynamicgraph::ExceptionAbstract::Param::Param
Param()
dynamicgraph::ExceptionAbstract::what
virtual const char * what() const
line
int line
dynamicgraph::ExceptionAbstract::getExceptionName
virtual const std::string & getExceptionName() const


sot-core
Author(s): Olivier Stasse, ostasse@laas.fr
autogenerated on Tue Oct 24 2023 02:26:31