表格线识别通用库文档
载入中...
搜索中...
未找到
cm::Exception类 参考

通用异常类 更多...

#include <type.h>

类 cm::Exception 继承关系图:
cm::Exception 的协作图:

Public 成员函数

 Exception (const std::string &exception_info)
 通用异常类的构造函数
 
const charwhat () const noexcept override
 获取异常的描述信息
 

详细描述

通用异常类

该类表示一个通用的异常,支持自定义异常消息。可以通过构造函数传入异常消息,并通过重写 what() 方法来获取异常描述信息。

作者
dreamy-xay
日期
2024-02-29

在文件 type.h39 行定义.

构造及析构函数说明

◆ Exception()

cm::Exception::Exception ( const std::string & exception_info)
inline

通用异常类的构造函数

通过给定的异常消息构造一个异常。

参数
exception_info异常消息

示例
// 方向错误时抛出异常
switch (pos) {
case LEFT:
return 0;
case RIGHT:
return 1;
default:
throw Exception("The \"position\" only supports \"LEFT\" or \"RIGHT\" types!");
}
}
Exception(const std::string &exception_info)
通用异常类的构造函数
Definition type.h:70
点类
Definition point.hpp:52
Position
位置枚举
Definition enum.h:84
@ RIGHT
Definition enum.h:90
@ LEFT
Definition enum.h:86
作者
dreamy-xay
日期
2024-02-29

在文件 type.h70 行定义.

成员函数说明

◆ what()

const char * cm::Exception::what ( ) const
inlineoverridenoexcept

获取异常的描述信息

返回
异常的描述信息,以C风格字符串形式返回
示例
TestCmException 函数见 Exception 示例
// 捕获异常消息
try {
} catch(const std::exception& e) {
std::cout << e.what() << "\n";
}
作者
dreamy-xay
日期
2024-02-29

在文件 type.h91 行定义.


该类的文档由以下文件生成: