|
1 | | -#include <functional> |
2 | | -#include "core/common/exceptions.h" |
3 | | - |
4 | | -namespace Lotus { |
5 | | - |
6 | | -static std::function<string(void)> FetchStackTrace = []() { return ""; }; |
7 | | - |
8 | | -EnforceNotMet::EnforceNotMet( |
9 | | - const char* file, |
10 | | - const int line, |
11 | | - const char* condition, |
12 | | - const string& msg, |
13 | | - const void* caller) |
14 | | - : msg_stack_{MakeString( |
15 | | - "[enforce fail at ", |
16 | | - StripBasename(std::string(file)), |
17 | | - ":", |
18 | | - line, |
19 | | - "] ", |
20 | | - condition, |
21 | | - ". ", |
22 | | - msg, |
23 | | - " ")}, |
24 | | - stack_trace_(FetchStackTrace()) { |
25 | | - caller_ = caller; |
26 | | - full_msg_ = this->Msg(); |
27 | | -} |
28 | | - |
29 | | -void EnforceNotMet::AppendMessage(const string& msg) { |
30 | | - msg_stack_.push_back(msg); |
31 | | - full_msg_ = this->Msg(); |
32 | | -} |
33 | | - |
34 | | -string EnforceNotMet::Msg() const { |
35 | | - return std::accumulate(msg_stack_.begin(), msg_stack_.end(), string("")) + |
36 | | - stack_trace_; |
37 | | -} |
38 | | - |
39 | | -const char* EnforceNotMet::what() const noexcept { |
40 | | - return full_msg_.c_str(); |
41 | | -} |
42 | | - |
43 | | -const void* EnforceNotMet::Caller() const noexcept { |
44 | | - return caller_; |
45 | | -} |
46 | | -} // namespace Lotus |
| 1 | +#include <functional> |
| 2 | +#include "core/common/exceptions.h" |
| 3 | + |
| 4 | +namespace Lotus { |
| 5 | + |
| 6 | +static std::function<string(void)> FetchStackTrace = []() { return ""; }; |
| 7 | + |
| 8 | +EnforceNotMet::EnforceNotMet( |
| 9 | + const char* file, |
| 10 | + const int line, |
| 11 | + const char* condition, |
| 12 | + const string& msg, |
| 13 | + const void* caller) |
| 14 | + : msg_stack_{MakeString( |
| 15 | + "[enforce fail at ", |
| 16 | + StripBasename(std::string(file)), |
| 17 | + ":", |
| 18 | + line, |
| 19 | + "] ", |
| 20 | + condition, |
| 21 | + ". ", |
| 22 | + msg, |
| 23 | + " ")}, |
| 24 | + stack_trace_(FetchStackTrace()) { |
| 25 | + caller_ = caller; |
| 26 | + full_msg_ = this->Msg(); |
| 27 | +} |
| 28 | + |
| 29 | +void EnforceNotMet::AppendMessage(const string& msg) { |
| 30 | + msg_stack_.push_back(msg); |
| 31 | + full_msg_ = this->Msg(); |
| 32 | +} |
| 33 | + |
| 34 | +string EnforceNotMet::Msg() const { |
| 35 | + return std::accumulate(msg_stack_.begin(), msg_stack_.end(), string("")) + |
| 36 | + stack_trace_; |
| 37 | +} |
| 38 | + |
| 39 | +const char* EnforceNotMet::what() const noexcept { |
| 40 | + return full_msg_.c_str(); |
| 41 | +} |
| 42 | + |
| 43 | +const void* EnforceNotMet::Caller() const noexcept { |
| 44 | + return caller_; |
| 45 | +} |
| 46 | +} // namespace Lotus |
0 commit comments