1 |
|
|
/* |
2 |
|
|
* Copyright 2010, |
3 |
|
|
* François Bleibel, |
4 |
|
|
* Olivier Stasse, |
5 |
|
|
* |
6 |
|
|
* CNRS/AIST |
7 |
|
|
* |
8 |
|
|
*/ |
9 |
|
|
|
10 |
|
|
#include <dynamic-graph/debug.h> |
11 |
|
|
#include <dynamic-graph/exception-factory.h> |
12 |
|
|
#include <stdarg.h> |
13 |
|
|
|
14 |
|
|
#include <cstdio> |
15 |
|
|
|
16 |
|
|
using namespace dynamicgraph; |
17 |
|
|
|
18 |
|
|
/* --------------------------------------------------------------------- */ |
19 |
|
|
/* --- CLASS ----------------------------------------------------------- */ |
20 |
|
|
/* --------------------------------------------------------------------- */ |
21 |
|
|
|
22 |
|
|
const std::string ExceptionFactory::EXCEPTION_NAME = "Factory"; |
23 |
|
|
|
24 |
|
3 |
ExceptionFactory::ExceptionFactory( |
25 |
|
3 |
const ExceptionFactory::ErrorCodeEnum &errcode, const std::string &msg) |
26 |
✓✗ |
3 |
: ExceptionAbstract(errcode, msg) { |
27 |
|
3 |
dgDEBUGF(15, "Created with message <%s>.", msg.c_str()); |
28 |
|
|
dgDEBUG(1) << "Created with message <%s>." << msg << std::endl; |
29 |
|
3 |
} |
30 |
|
|
|
31 |
|
12 |
ExceptionFactory::ExceptionFactory( |
32 |
|
|
const ExceptionFactory::ErrorCodeEnum &errcode, const std::string &msg, |
33 |
|
12 |
const char *format, ...) |
34 |
✓✗ |
12 |
: ExceptionAbstract(errcode, msg) { |
35 |
|
|
va_list args; |
36 |
|
12 |
va_start(args, format); |
37 |
|
|
|
38 |
|
12 |
const unsigned int SIZE = 256; |
39 |
|
|
char buffer[SIZE]; |
40 |
|
12 |
vsnprintf(buffer, SIZE, format, args); |
41 |
|
|
|
42 |
|
|
dgDEBUG(15) << "Created " |
43 |
|
|
<< " with message <" << msg << "> and buffer <" << buffer << ">. " |
44 |
|
|
<< std::endl; |
45 |
|
|
|
46 |
✓✗ |
12 |
message += buffer; |
47 |
|
|
|
48 |
|
12 |
va_end(args); |
49 |
|
|
|
50 |
|
|
dgDEBUG(1) << "Throw exception " << EXCEPTION_NAME << "[#" << errcode << "]: " |
51 |
|
|
<< "<" << message << ">." << std::endl; |
52 |
|
12 |
} |
53 |
|
|
|
54 |
|
|
/* |
55 |
|
|
* Local variables: |
56 |
|
|
* c-basic-offset: 2 |
57 |
|
|
* End: |
58 |
|
|
*/ |