faio
faio 公共 C++ 接口参考
载入中...
搜索中...
未找到
faio::Error类 参考

携带错误来源、原生错误码和已完成传输进度的错误值。 更多...

Public 类型

enum  ErrorCode {
  EmptySqe = 1000 , InvalidAddresses , ClosedChannel , UnexpectedEOF ,
  WriteZero , TooLongTime , PassedTime , InvalidSocketType ,
  ReuniteFailed
}
 faio 自定义错误码;具体数值与系统错误域分开解释。 更多...

Public 成员函数

 Error (int err_code, std::uint64_t transferred=0, error_domain domain=error_domain::posix)
 构造Error对象。
std::uint64_t transferred () const noexcept
 读取错误发生前已经生效的传输量。
std::uint64_t progress () const noexcept
 读取已完成传输量。
error_domain domain () const noexcept
 读取错误所属来源。
std::int64_t native_code () const noexcept
 读取原生错误码。
const std::shared_ptr< const error_context > & context () const noexcept
 借用错误持有的诊断上下文。
Error with_context (std::shared_ptr< const error_context > details) const
 复制错误并附加共享诊断。
Error with_progress (std::uint64_t bytes) const
 复制错误并更新累计进度。
int value () const noexcept
 读取错误码或权限数值。
std::string_view message () const noexcept
 读取可读错误说明。

详细描述

携带错误来源、原生错误码和已完成传输进度的错误值。

公共头文件
#include <faio/common/error.hpp>

成员枚举类型说明

◆ ErrorCode

faio 自定义错误码;具体数值与系统错误域分开解释。

枚举值
EmptySqe 

没有可用的提交队列项。

InvalidAddresses 

没有可以使用的目标地址。

ClosedChannel 

通道已关闭。

UnexpectedEOF 

缓冲区填满前遇到 EOF。

WriteZero 

非空写入没有产生任何进度。

TooLongTime 

请求的等待时间超出支持范围。

PassedTime 

指定时间已经过去。

InvalidSocketType 

原生 socket 类型不匹配。

ReuniteFailed 

尝试合并不同来源的读写半部。

构造及析构函数说明

◆ Error()

faio::Error::Error ( int err_code,
std::uint64_t transferred = 0,
error_domain domain = error_domain::posix )
explicit

构造Error对象。

参数
err_code错误码;与 domain 一起解释,不能把所有来源都视为 errno。
transferred错误发生前已经生效的字节数。 默认值:0。
domain原生错误的来源标识。 默认值:error_domain::posix。
返回值
构造函数不返回值。
注解
对象的复制、移动和资源所有权遵循类型说明。

成员函数说明

◆ transferred()

std::uint64_t faio::Error::transferred ( ) const
noexcept

读取错误发生前已经生效的传输量。

返回
返回 uint64_t 字节数。

◆ progress()

std::uint64_t faio::Error::progress ( ) const
noexcept

读取已完成传输量。

返回
返回 uint64_t,与 transferred() 一致。

◆ domain()

error_domain faio::Error::domain ( ) const
noexcept

读取错误所属来源。

返回
返回 error_domain,不应统一按 errno 解释。

◆ native_code()

std::int64_t faio::Error::native_code ( ) const
noexcept

读取原生错误码。

返回
返回 int64_t。

◆ context()

const std::shared_ptr< const error_context > & faio::Error::context ( ) const
noexcept

借用错误持有的诊断上下文。

返回
返回const shared_ptr<const error_context>&;没有上下文时为空。
注解
借用期间须保持Error对象存活。

◆ with_context()

Error faio::Error::with_context ( std::shared_ptr< const error_context > details) const

复制错误并附加共享诊断。

参数
details与错误副本共享的不可变诊断上下文。
返回
返回保留错误码、错误域及进度的新Error。

◆ with_progress()

Error faio::Error::with_progress ( std::uint64_t bytes) const

复制错误并更新累计进度。

参数
bytes可写字节缓冲区;在操作完成前保持内存与地址有效,不能被其他任务无序修改。
返回
返回保留错误域和诊断上下文的新Error。

◆ value()

int faio::Error::value ( ) const
noexcept

读取错误码或权限数值。

返回
返回当前对象的值,具体类型见签名。

◆ message()

std::string_view faio::Error::message ( ) const
noexcept

读取可读错误说明。

返回
返回 string_view,视图不拥有字符串。