forked from samunders-core/le_disasm
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patherror.h
40 lines (31 loc) · 894 Bytes
/
error.h
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
#ifndef LE_DISASM_ERROR_H_
#define LE_DISASM_ERROR_H_
#include <sstream>
#include <stdexcept>
#include <string>
#include "stacktrace.h"
// http://marknelson.us/2007/11/13/no-exceptions/
// throw Error() <<"Game over, "
// <<mHealth
// <<" health points!";
struct Error : public std::exception {
Error() { print_stacktrace(); }
Error(const Error& that) { mWhat += that.mStream.str(); }
virtual ~Error() throw(){};
virtual const char* what() const throw() {
if (mStream.str().size()) {
mWhat += mStream.str();
mStream.str("");
}
return mWhat.c_str();
}
template <typename T>
Error& operator<<(const T& t) {
mStream << t;
return *this;
}
private:
mutable std::stringstream mStream;
mutable std::string mWhat;
};
#endif /* LE_DISASM_ERROR_H_ */