forked from augcampos/asterisk-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathException.cpp
More file actions
75 lines (56 loc) · 1.88 KB
/
Exception.cpp
File metadata and controls
75 lines (56 loc) · 1.88 KB
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
/*
* Exception.cpp
*
* Created on: 29 de Jun de 2011
* Author: augcampos
*/
#include "asteriskcpp/exceptions/ExceptionHandler.h"
#include "asteriskcpp/exceptions/Exception.h"
#include "asteriskcpp/utils/LogHandler.h"
namespace asteriskcpp {
Exception::Exception(const std::string& message) {
this->name = "Exception";
this->message = message;
this->stackTrace = ExceptionHandler::getStackTraceString();
}
Exception::~Exception() throw () {
}
void Exception::printStackTrace() {
const std::string& stackTrace = this->getStackTrace();
LOG_ERROR_STR(stackTrace);
}
std::string Exception::getStackTrace() {
std::string result;
std::stringstream stream;
stream << this->stackTrace;
stream << this->information << std::endl;
stream << this->name << ": " << this->message;
result = stream.str();
return (result);
}
void Exception::setExceptionInformation(const char* file, const char* function, const int line) {
std::stringstream stream;
stream << file << ": line " << line << " on " << function;
this->information = stream.str();
}
std::string Exception::getMessage() {
std::string result;
std::stringstream stream;
stream << this->name << ": " << this->message;
result = stream.str();
return (result);
}
std::string Exception::getInformation() {
std::string result;
std::stringstream stream;
stream << this->information << std::endl;
stream << this->name << ": " << this->message;
result = stream.str();
return (result);
}
Exception::Exception(const std::string& name, const std::string& message) {
this->name = name;
this->message = message;
this->stackTrace = ExceptionHandler::getStackTraceString();
}
}