本文整理汇总了C++中std::error_code::category方法的典型用法代码示例。如果您正苦于以下问题:C++ error_code::category方法的具体用法?C++ error_code::category怎么用?C++ error_code::category使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::error_code
的用法示例。
在下文中一共展示了error_code::category方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
static mb::optional<int> extract_errno(std::error_code ec)
{
if (ec.category() == std::generic_category()
|| ec.category() == std::system_category()) {
return ec.value();
}
return {};
}
示例2: is_session_level_protocol_error
/// The error is a connection-level protocol error.
bool is_session_level_protocol_error() const
{
if (error_code.category() != realm::sync::protocol_error_category()) {
return false;
}
return realm::sync::is_session_level_error(static_cast<ProtocolError>(error_code.value()));
}
示例3: handleMergeWriterError
static void handleMergeWriterError(std::error_code &Error,
StringRef WhenceFile = "",
StringRef WhenceFunction = "",
bool ShowHint = true) {
if (!WhenceFile.empty())
errs() << WhenceFile << ": ";
if (!WhenceFunction.empty())
errs() << WhenceFunction << ": ";
errs() << Error.message() << "\n";
if (ShowHint) {
StringRef Hint = "";
if (Error.category() == instrprof_category()) {
instrprof_error instrError = static_cast<instrprof_error>(Error.value());
switch (instrError) {
case instrprof_error::hash_mismatch:
case instrprof_error::count_mismatch:
case instrprof_error::value_site_count_mismatch:
Hint = "Make sure that all profile data to be merged is generated "
"from the same binary.";
break;
default:
break;
}
}
if (!Hint.empty())
errs() << Hint << "\n";
}
}
示例4: pack
static inline
void
pack(msgpack::packer<Stream>& target, const std::error_code& source) {
int category_id = error::registrar::map(source.category());
int ec = source.value();
type_traits<sequence_type>::pack(target, category_id, ec);
}
示例5: FormatError
std::string FormatError(std::error_code err)
{
#if BOOST_OS_WINDOWS
if (err.category() == std::system_category())
err.assign(err.value(), ext::system_utf8_category());
#endif
return FormatErrorImpl(err);
}
示例6: _networkErrorCallback
void NetworkInterfaceASIO::_networkErrorCallback(AsyncOp* op, const std::error_code& ec) {
if (ec.category() == mongoErrorCategory()) {
// If we get a Mongo error code, we can preserve it.
_completeOperation(op, Status(ErrorCodes::fromInt(ec.value()), ec.message()));
} else {
// If we get an asio or system error, we just convert it to a network error.
_completeOperation(op, Status(ErrorCodes::HostUnreachable, ec.message()));
}
}
示例7: is_client_reset_requested
/// The error indicates a client reset situation.
bool is_client_reset_requested() const
{
if (error_code.category() != realm::sync::protocol_error_category()) {
return false;
}
// Documented here: https://realm.io/docs/realm-object-server/#client-recovery-from-a-backup
return (error_code == ProtocolError::bad_server_file_ident
|| error_code == ProtocolError::bad_client_file_ident
|| error_code == ProtocolError::bad_server_version
|| error_code == ProtocolError::diverging_histories);
}
示例8: exitWithErrorCode
static void exitWithErrorCode(const std::error_code &Error, StringRef Whence = "") {
if (Error.category() == instrprof_category()) {
instrprof_error instrError = static_cast<instrprof_error>(Error.value());
if (instrError == instrprof_error::unrecognized_format) {
// Hint for common error of forgetting -sample for sample profiles.
exitWithError(Error.message(), Whence,
"Perhaps you forgot to use the -sample option?");
}
}
exitWithError(Error.message(), Whence);
}
示例9: do_error
virtual void do_error(std::error_code ec,
const parsing_context& context) throw(json_parse_exception)
{
if (ec.category() == json_error_category())
{
if (ec.value() != value_)
{
default_parse_error_handler::instance().error(ec,context);
}
}
}
示例10: do_error
virtual void do_error(std::error_code ec,
const parsing_context& context) throw(parse_exception)
{
if (ec.category() == json_error_category())
{
if (ec.value() != jsoncons::json_parser_errc::extra_comma && (context.current_char() == ']' || context.current_char() == '}'))
{
default_parse_error_handler::instance().error(ec,context);
}
}
}
示例11: if
any
rpc::make_error( std::error_code err )
{
any reply;
if ( err.category() == rpc::error_category() )
{
reply[ "error" ][ "code" ] = err.value();
reply[ "error" ][ "message" ] = err.message();
}
else if ( is_user_defined_error( err.value() ) )
{
reply[ "error" ][ "code" ] = err.value();
reply[ "error" ][ "message" ] = err.message();
}
else
{
reply[ "error" ][ "code" ] = errc::internal_error;
reply[ "error" ][ "message" ] = "unknown";
}
return reply;
}
示例12: is_client_error
/// The error is a client error, which applies to the client and all its sessions.
bool is_client_error() const
{
return error_code.category() == realm::sync::client_error_category();
}
示例13: _networkErrorCallback
void NetworkInterfaceASIO::_networkErrorCallback(AsyncOp* op, const std::error_code& ec) {
ErrorCodes::Error errorCode = (ec.category() == mongoErrorCategory())
? ErrorCodes::fromInt(ec.value())
: ErrorCodes::HostUnreachable;
_completeOperation(op, {errorCode, ec.message(), Milliseconds(now() - op->_start)});
}
示例14: error
void operation::error( const std::error_code& code ) {
Internal = code.value();
InternalHigh = reinterpret_cast< ULONG_PTR >(&code.category());
}