51 lines
1.1 KiB
C++
51 lines
1.1 KiB
C++
/**
|
|
* @file mix_cc/exception/exception.h
|
|
* @brief mix_cc的异常类
|
|
* @author Cat (null.null.null@qq.com)
|
|
* @version 0.1
|
|
* @date 2021-09-17
|
|
*
|
|
* Copyright: Baosight Co. Ltd.
|
|
* DO NOT COPY/USE WITHOUT PERMISSION
|
|
*
|
|
*/
|
|
#pragma once
|
|
#include "mix_cc/json.h"
|
|
#include <exception>
|
|
#include <string>
|
|
#include <thread>
|
|
#include <boost/assert/source_location.hpp>
|
|
|
|
namespace mix_cc {
|
|
/**
|
|
* @brief mix_cc内部的异常处理类
|
|
*/
|
|
class Exception : public std::runtime_error {
|
|
public:
|
|
/**
|
|
* @brief 构建mix_cc内部的异常处理类
|
|
* @param error_code 错误号(int)
|
|
* @param error_info 错误信息(string)
|
|
* @param src_loc 异常发生的源代码的位置
|
|
* @param extra_info 额外信息
|
|
*/
|
|
Exception(int error_code, const std::string error_info,
|
|
const boost::source_location src_loc, const json extra_info_ = {});
|
|
|
|
/**
|
|
* @brief Destroy the Exception object
|
|
*/
|
|
~Exception();
|
|
|
|
/**
|
|
* @brief Get the thread name object
|
|
* @return std::string
|
|
*/
|
|
size_t get_thread_id() const;
|
|
|
|
protected:
|
|
std::thread::id thread_id_;
|
|
};
|
|
|
|
} // namespace mix_cc
|