GCC Code Coverage Report


Directory: ./
File: src/exception/exception-abstract.cpp
Date: 2024-08-13 12:13:25
Exec Total Coverage
Lines: 0 14 0.0%
Branches: 0 2 0.0%

Line Branch Exec Source
1 /*
2 * Copyright 2010,
3 * François Bleibel,
4 * Olivier Stasse,
5 *
6 * CNRS/AIST
7 *
8 */
9
10 #include <sot/core/debug.hh>
11 #include <sot/core/exception-abstract.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
38 const string &ExceptionAbstract::getStringMessage(void) {
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
51 ExceptionAbstract::Param &ExceptionAbstract::Param::initCopy(const Param &p) {
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
91 /** \file $Source$
92 */
93
94 /*
95 * Local variables:
96 * c-basic-offset: 2
97 * End:
98 */
99