#include <CommonException.h>
|
| 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 () override=default |
|
| CommonException (const CommonException &)=default |
|
CommonException & | operator= (const CommonException &)=default |
|
| CommonException (CommonException &&) noexcept=default |
|
CommonException & | operator= (CommonException &&) noexcept=default |
|
std::string | getStackTrace () const |
|
uint64_t | getCode () const |
|
std::string | getMessage () const |
|
char const * | what () const ALS_EXCEPTION_NOEXCEPT override |
|
通用异常
大部分 API 接口都可能会抛出异常,异常类型要么是 CommonException,要么是 CommonException 的子类。 我们应该捕获异常,并采取合适的逻辑处理异常,如下示例展示了如何捕获并处理异常。
try {
}
}
else if (cause.
getCode() == 152006) {
}
else {
}
}
std::string getStackTrace() const
- 自从
- 0.4.0
在文件 CommonException.h 第 71 行定义.
◆ CommonException() [1/5]
ALSON::CommonException::CommonException |
( |
uint64_t | code, |
|
|
const std::string & | message, |
|
|
uint64_t | line = 0, |
|
|
const std::string & | filename = "" ) |
◆ CommonException() [2/5]
ALSON::CommonException::CommonException |
( |
CommonException & | cause, |
|
|
uint64_t | code, |
|
|
const std::string & | message, |
|
|
uint64_t | line = 0, |
|
|
const std::string & | filename = "" ) |
◆ CommonException() [3/5]
ALSON::CommonException::CommonException |
( |
std::exception & | cause, |
|
|
uint64_t | code, |
|
|
const std::string & | message, |
|
|
uint64_t | line = 0, |
|
|
const std::string & | filename = "" ) |
◆ ~CommonException()
ALSON::CommonException::~CommonException |
( |
| ) |
|
|
overridedefault |
◆ CommonException() [4/5]
◆ CommonException() [5/5]
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ getStackTrace()
std::string ALSON::CommonException::getStackTrace |
( |
| ) |
const |
获取一个由异常堆栈组成的字符串
- 返回
- 一个由异常堆栈组成的字符串
◆ getCode()
uint64_t ALSON::CommonException::getCode |
( |
| ) |
const |
◆ getMessage()
std::string ALSON::CommonException::getMessage |
( |
| ) |
const |
◆ what()
char const * ALSON::CommonException::what |
( |
| ) |
const |
|
override |
获取当前异常的详细信息
作用等同于 getMessage 函数,为兼容 std::exception 而设置
- 返回
- 当前异常的详细信息