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 {}; }
/// 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())); }
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"; } }
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); }
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); }
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())); } }
/// 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); }
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); }
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); } } }
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); } } }
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; }
/// 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(); }
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)}); }
void operation::error( const std::error_code& code ) { Internal = code.value(); InternalHigh = reinterpret_cast< ULONG_PTR >(&code.category()); }