首页 > 其他 > 详细

muduo 库解析之四:Exception

时间:2021-04-24 16:19:23      阅读:90      评论:0      收藏:0      [点我收藏+]

源码

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))
    {
    }
}

muduo 库解析之四:Exception

原文:https://www.cnblogs.com/xiaojianliu/p/14696660.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!