NexusForce 1.0.0
A rigorously engineered full-stack C++ backend library.
载入中...
搜索中...
未找到
异常处理

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

异常处理 的协作图:

专题

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

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

宏定义

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

函数

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

详细描述

异常处理类与工具

宏定义说明

◆ 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) \
};

构建可派生的异常类宏

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

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

在文件 exception.hpp44 行定义.

被这些函数引用 neforce::allocate_exception::type(), neforce::database_exception::type(), neforce::thirdparty_exception::type(), neforce::typecast_exception::type() , 以及 neforce::value_exception::type().

◆ 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.hpp60 行定义.

函数说明

◆ current_exception()

exception_ptr neforce::current_exception ( )
noexcept

获取当前异常

返回
当前异常的异常指针

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

引用了 current_exception().

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

◆ make_exception_ptr()

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

创建异常指针

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

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

在文件 exception_ptr.hpp325 行定义.

◆ rethrow_exception()

void neforce::rethrow_exception ( const exception_ptr & p)

◆ throw_with_stack()

void neforce::throw_with_stack ( const exception & err)

抛出异常并打印堆栈信息

参数
err要抛出的异常对象

引用了 throw_with_stack().

被这些函数引用 throw_with_stack().

◆ uncaught_exceptions()

int neforce::uncaught_exceptions ( )
noexcept

未捕获的异常数量

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

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

引用了 uncaught_exceptions().

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