Newer
Older
Francois Bleibel
committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* Copyright Projet JRL-Japan, 2007
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*
* File: ExceptionAbstract.cpp
* Project: SOT
* Author: Nicolas Mansard
*
* Version control
* ===============
*
* $Id$
*
* Description
* ============
*
*
* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
#include <dynamicGraph/exception-abstract.h>
#include <dynamicGraph/debug.h>
using namespace std;
using namespace dynamicgraph;
/* ------------------------------------------------------------------------- */
/* --- CONSTRUCTORS -------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
const std::string ExceptionAbstract::EXCEPTION_NAME = "Abstract";
ExceptionAbstract::
ExceptionAbstract (const int& _code,
const string & _msg)
:
code (_code),
message (_msg)
{
return ;
}
/* ------------------------------------------------------------------------ */
/* --- ACCESSORS ---------------------------------------------------------- */
/* ------------------------------------------------------------------------ */
const char *ExceptionAbstract::
getMessage (void)
{
return (this->message) .c_str();
}
const string &ExceptionAbstract::
getStringMessage (void)
{
return this->message;
}
int ExceptionAbstract::
getCode (void)
{
return this->code;
}
/* ------------------------------------------------------------------------- */
/* --- MODIFIORS ----------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
#ifdef SOT_EXCEPTION_PASSING_PARAM
ExceptionAbstract::Param& ExceptionAbstract::Param::
initCopy( const Param& p )
{
dgDEBUGIN(25);
if( p.pointersSet )
{
strncpy( function,p.functionPTR,BUFFER_SIZE);
strncpy( file,p.filePTR,BUFFER_SIZE);
line = p.line;
pointersSet=false;
set=true;
} else set=false;
dgDEBUGOUT(25);
return *this;
}
ExceptionAbstract::Param::
Param( const int& _line, const char * _function, const char * _file )
: functionPTR(_function),line(_line),filePTR(_file),pointersSet(true)
{
dgDEBUGINOUT(25);
}
#endif //#ifdef SOT_EXCEPTION_PASSING_PARAM
/* ------------------------------------------------------------------------- */
/* --- OP << --------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
namespace dynamicgraph {
ostream &
operator << (ostream & os,
const ExceptionAbstract & error)
{
os << error.getExceptionName()<<"Error [#" << error.code << "]: " << error.message << endl;
#ifdef SOT_EXCEPTION_PASSING_PARAM
if( error.p.set )
os << "Thrown from "<<error.p.file << ": "<<error.p.function
<<" (#"<<error.p.line << ")"<<endl;
#endif //#ifdef SOT_EXCEPTION_PASSING_PARAM
return os;
}
} // namespace dynamicgraph
/** \file $Source$
*/
/*
* Local variables:
* c-basic-offset: 4
* End:
*/