0.4.3
CommonException.h
浏览该文件的文档.
1//
2// Created by ALSON08 on 2024/1/25.
3//
4
5#ifndef ALSON_COMMUNICATION_BASE_EXCEPTION_COMMON_EXCEPTION_H
6#define ALSON_COMMUNICATION_BASE_EXCEPTION_COMMON_EXCEPTION_H
7
8
9// std
10#include <cstdint>
11#include <string>
12#include <memory>
13#include <exception>
14
15// alson
17
18
19#ifndef ALS_EXCEPTION_NOEXCEPT
20# if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
21# define ALS_EXCEPTION_NOEXCEPT
22# elif __linux__
23# define ALS_EXCEPTION_NOEXCEPT noexcept
24# endif
25#endif
26
27
28namespace ALSON {
29
30
31class CommonExceptionImpl;
32using CommonExceptionImplPtr = std::shared_ptr<CommonExceptionImpl>;
33
71class ALSON_API CommonException : public std::exception {
72public:
73 CommonException(uint64_t code, const std::string& message, uint64_t line = 0, const std::string& filename = "");
74 CommonException(CommonException& cause, uint64_t code, const std::string& message, uint64_t line = 0, const std::string& filename = "");
75 CommonException(std::exception& cause, uint64_t code, const std::string& message, uint64_t line = 0, const std::string& filename = "");
76 ~CommonException() override = default;
79 CommonException(CommonException&&) noexcept = default;
80 CommonException& operator=(CommonException&&) noexcept = default;
81
82public:
94 std::string getStackTrace() const;
95
107 uint64_t getCode() const;
108
120 std::string getMessage() const;
121
139 char const* what() const ALS_EXCEPTION_NOEXCEPT override;
140
141private:
142 CommonExceptionImplPtr m_commonExceptionImplPtr;
143}; // class CommonException
144
145
146} // namespace ALSON
147
148
149#endif // !ALSON_COMMUNICATION_BASE_EXCEPTION_COMMON_EXCEPTION_H
CommonException(CommonException &&) noexcept=default
~CommonException() override=default
CommonException(const CommonException &)=default
CommonException(uint64_t code, const std::string &message, uint64_t line=0, const std::string &filename="")
CommonException(CommonException &cause, uint64_t code, const std::string &message, uint64_t line=0, const std::string &filename="")
CommonException(std::exception &cause, uint64_t code, const std::string &message, uint64_t line=0, const std::string &filename="")
CommonException & operator=(const CommonException &)=default
#define ALSON_API
std::shared_ptr< CommonExceptionImpl > CommonExceptionImplPtr
My Custom Doxygen Footer
Data Processing Programmer's Guide 0.4.3
Copyright © 2014-2024 Henan Alson Intelligent Technology Co, Ltd 河南埃尔森智能科技有限公司 版权所有 豫ICP备15002212号