源码
Exception.h
#pragmae once
#include <exception>
#include <string>
namespace muduo
{
class Exception : public std::exception
{
public:
explicit Exception(std::string msg);
~Exception() noexcept override = default;
const char *what() const noexcept override //@ 重载
{
return msg_.c_str();
}
const char *stack() const noexcept
{
return stack_.c_str();
}
private:
std::string msg_;
std::stirng stack_;
}
}
Exception.cc
#include "Exception.h"
#include "CurrentThread.h"
namespace muduo
{
Exception::Exception(std::string msg) : msg_(std::move(msg)), stack_(CurrentThread::stack_trace(false))
{
}
}