NexusForce 1.0.0
A Modern C++ Library with extended functionality, web components, and utility libraries
载入中...
搜索中...
未找到
异常处理

异常处理类与工具 更多...

异常处理 的协作图:

专题

 异常类集
 全部异常类的集合

class  exception_wrapper
 异常包装器基类 更多...
class  typed_exception_wrapper< Ex >
 类型化异常包装器模板类 更多...
class  exception_ptr
 异常指针类 更多...

宏定义

#define NEFORCE_ERROR_BUILD_DERIVED_CLASS(THIS, BASE, INFO)
 构建可派生的异常类宏
#define NEFORCE_ERROR_BUILD_FINAL_CLASS(THIS, BASE, INFO)
 构建最终异常类宏

函数

int NEFORCE_API uncaught_exceptions () noexcept NEFORCE_PURE_FUNCTION
 未捕获的异常数量
void NEFORCE_API throw_with_stack (const exception &err)
 抛出异常并打印堆栈信息
template<typename Ex>
exception_ptr make_exception_ptr (Ex ex)
 创建异常指针
exception_ptr NEFORCE_API current_exception ()
 获取当前异常
void NEFORCE_API rethrow_exception (const exception_ptr &p)
 重新抛出异常

详细描述

异常处理类与工具

宏定义说明

◆ NEFORCE_ERROR_BUILD_DERIVED_CLASS

#define NEFORCE_ERROR_BUILD_DERIVED_CLASS ( THIS,
BASE,
INFO )
值:
struct THIS : BASE { \
__NEFORCE_ERROR_CONSTRUCTOR(THIS, BASE, INFO) \
__NEFORCE_ERROR_DERIVED_DESTRUCTOR(THIS) \
__NEFORCE_ERROR_TYPE(THIS) \
};
@ INFO
信息级别,普通信息

构建可派生的异常类宏

参数
THIS当前类名
BASE基类名
INFO默认错误信息

快速定义可进一步派生的异常类。

在文件 exception.hpp43 行定义.

◆ NEFORCE_ERROR_BUILD_FINAL_CLASS

#define NEFORCE_ERROR_BUILD_FINAL_CLASS ( THIS,
BASE,
INFO )
值:
struct THIS final : BASE { \
__NEFORCE_ERROR_CONSTRUCTOR(THIS, BASE, INFO) \
__NEFORCE_ERROR_FINAL_DESTRUCTOR(THIS) \
__NEFORCE_ERROR_TYPE(THIS) \
};

构建最终异常类宏

参数
THIS当前类名
BASE基类名
INFO默认错误信息

快速定义不可派生的异常类。

在文件 exception.hpp59 行定义.

函数说明

◆ current_exception()

exception_ptr NEFORCE_API current_exception ( )
noexcept

获取当前异常

返回
当前异常的异常指针

捕获当前异常并创建异常指针。 如果当前没有异常被捕获,返回空的异常指针。

被这些函数引用 retry(), generator< T >::promise_type::unhandled_exception(), task< T >::promise_type::unhandled_exception() , 以及 virtual_thread_task::promise_type::unhandled_exception().

◆ make_exception_ptr()

template<typename Ex>
exception_ptr make_exception_ptr ( Ex ex)
noexcept

创建异常指针

模板参数
Ex异常类型
参数
ex异常对象
返回
异常指针

创建引用指定异常的异常指针。 如果内存分配失败,返回空的异常指针。

在文件 exception_ptr.hpp314 行定义.

◆ rethrow_exception()

void NEFORCE_API rethrow_exception ( const exception_ptr & p)

重新抛出异常

参数
p异常指针

重新抛出异常指针引用的异常。

注解
如果异常指针为空,进程将被终止。

引用了 rethrow_exception().

被这些函数引用 task< T >::awaiter::await_resume(), generator< T >::begin(), task< T >::get(), rethrow_exception() , 以及 retry().

◆ throw_with_stack()

void NEFORCE_API throw_with_stack ( const exception & err)

抛出异常并打印堆栈信息

参数
err要抛出的异常对象

引用了 throw_with_stack().

被这些函数引用 throw_with_stack().

◆ uncaught_exceptions()

int NEFORCE_API uncaught_exceptions ( )
noexcept

未捕获的异常数量

返回
当前线程中未捕获的异常数量

该函数返回在当前线程中已经抛出但尚未被捕获的异常数量。

引用了 uncaught_exceptions().

被这些函数引用 scope_fail< Func >::scope_fail(), scope_success< Func >::scope_success(), uncaught_exceptions(), scope_fail< Func >::~scope_fail() , 以及 scope_success< Func >::~scope_success().