/src/muduo/muduo/base/Exception.h
Line | Count | Source |
1 | | // Use of this source code is governed by a BSD-style license |
2 | | // that can be found in the License file. |
3 | | // |
4 | | // Author: Shuo Chen (chenshuo at chenshuo dot com) |
5 | | |
6 | | #ifndef MUDUO_BASE_EXCEPTION_H |
7 | | #define MUDUO_BASE_EXCEPTION_H |
8 | | |
9 | | #include "muduo/base/Types.h" |
10 | | #include <exception> |
11 | | |
12 | | namespace muduo |
13 | | { |
14 | | |
15 | | class Exception : public std::exception |
16 | | { |
17 | | public: |
18 | | Exception(string what); |
19 | | ~Exception() noexcept override = default; |
20 | | |
21 | | // default copy-ctor and operator= are okay. |
22 | | |
23 | | const char* what() const noexcept override |
24 | 0 | { |
25 | 0 | return message_.c_str(); |
26 | 0 | } |
27 | | |
28 | | const char* stackTrace() const noexcept |
29 | 0 | { |
30 | 0 | return stack_.c_str(); |
31 | 0 | } |
32 | | |
33 | | private: |
34 | | string message_; |
35 | | string stack_; |
36 | | }; |
37 | | |
38 | | } // namespace muduo |
39 | | |
40 | | #endif // MUDUO_BASE_EXCEPTION_H |