当前位置: 首页>>代码示例>>C++>>正文


C++ error_code::category方法代码示例

本文整理汇总了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 {};
}
开发者ID:Nonta72,项目名称:DualBootPatcher,代码行数:9,代码来源:fuse-sparse.cpp

示例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()));
 }
开发者ID:realm,项目名称:realm-object-store,代码行数:8,代码来源:sync_config.hpp

示例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";
  }
}
开发者ID:elfprince13,项目名称:llvm,代码行数:30,代码来源:llvm-profdata.cpp

示例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);
    }
开发者ID:3Hren,项目名称:cocaine-core,代码行数:8,代码来源:error_code.hpp

示例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);
	}
开发者ID:dmlys,项目名称:extlib,代码行数:9,代码来源:Errors.cpp

示例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()));
    }
}
开发者ID:AshishSanju,项目名称:mongo,代码行数:9,代码来源:network_interface_asio_command.cpp

示例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);
 }
开发者ID:realm,项目名称:realm-object-store,代码行数:12,代码来源:sync_config.hpp

示例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);
}
开发者ID:KristopherSmith,项目名称:llvm,代码行数:11,代码来源:llvm-profdata.cpp

示例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);
         }
     }
 }
开发者ID:Bigpet,项目名称:jsoncons,代码行数:11,代码来源:parse_string_tests.cpp

示例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);
         }
     }
 }
开发者ID:darcyg,项目名称:jsoncons,代码行数:11,代码来源:error_recovery_tests.cpp

示例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;
}
开发者ID:porchdog,项目名称:nodeoze,代码行数:23,代码来源:rpc.cpp

示例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();
 }
开发者ID:realm,项目名称:realm-object-store,代码行数:5,代码来源:sync_config.hpp

示例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)});
}
开发者ID:ChineseDr,项目名称:mongo,代码行数:6,代码来源:network_interface_asio_command.cpp

示例14: error

void operation::error( const std::error_code& code ) {
	Internal = code.value();
	InternalHigh = reinterpret_cast< ULONG_PTR >(&code.category());
}
开发者ID:aoziczero,项目名称:deprecated-tdk,代码行数:4,代码来源:operation.cpp


注:本文中的std::error_code::category方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。