本文整理汇总了C++中std::error_code类的典型用法代码示例。如果您正苦于以下问题:C++ error_code类的具体用法?C++ error_code怎么用?C++ error_code使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了error_code类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load_hosts
void protocol::load_hosts(const std::error_code& ec,
completion_handler handle_complete)
{
if (ec)
{
log_error(LOG_PROTOCOL)
<< "Could not load hosts file: " << ec.message();
handle_complete(ec);
return;
}
hosts_.fetch_count(strand_.wrap(
&protocol::if_0_seed, this, _1, _2, handle_complete));
}
示例2: handle_listen
void protocol::handle_listen(const std::error_code& ec, acceptor_ptr accept)
{
if (ec)
{
log_error(LOG_PROTOCOL)
<< "Error while listening: " << ec.message();
}
else
{
accept->accept(strand_.wrap(
&protocol::handle_accept, this, _1, _2, accept));
}
}
示例3: stealth_fetched
void stealth_fetched(const std::error_code& ec,
const blockchain::stealth_list& stealth_results)
{
if (ec)
{
log_error() << "Stealth fetch failed: " << ec.message();
return;
}
for (const blockchain::stealth_row& row: stealth_results)
log_debug() << "ephemkey: " << row.ephemkey
<< " address: " << row.address.encoded()
<< " tx_hash: " << row.transaction_hash;
}
示例4:
void
state_machine_t::terminate(std::error_code ec) {
BOOST_ASSERT(ec);
if (closed.exchange(true)) {
return;
}
COCAINE_LOG_DEBUG(log, "slave state machine is terminating: %s", ec.message());
auto state = *this->state.synchronize();
state->terminate(ec);
}
示例5: log_error
void protocol::handle_save(const std::error_code& ec,
completion_handler handle_complete)
{
if (ec)
{
log_error(LOG_PROTOCOL) << "Failed to save hosts '"
<< hosts_filename_ << "': " << ec.message();
handle_complete(ec);
return;
}
channel_subscribe_->relay(error::service_stopped, nullptr);
handle_complete(std::error_code());
}
示例6: connection_started
void connection_started(const std::error_code& ec, channel_ptr node,
protocol& prot)
{
if (ec)
{
log_warning() << "Couldn't start connection: " << ec.message();
return;
}
log_info() << "Connection established.";
// Resubscribe to new nodes.
prot.subscribe_channel(
std::bind(connection_started, _1, _2, std::ref(prot)));
}
示例7: makeNotCurrentImpl
bool GlxContext::makeNotCurrentImpl(std::error_code& ec)
{
ec.clear();
if(!::glXMakeCurrent(xDisplay(), 0, nullptr))
{
//TODO: handle error into ec
warning("ny::GlxContext::makeNotCurrentImpl (glXMakeCurrent) failed");
return false;
}
return true;
}
示例8: recv_block
void recv_block(std::error_code ec, libbitcoin::message::block block)
{
if (ec)
{
std::cerr << ec.message() << "\n";
return;
}
BITCOIN_ASSERT(block.transactions.size() == 2);
libbitcoin::hash_digest h1 = libbitcoin::hash_transaction(block.transactions[0]),
h2 = libbitcoin::hash_transaction(block.transactions[1]);
libbitcoin::hash_digest merkle = libbitcoin::generate_merkle_root(block.transactions);
BITCOIN_ASSERT((merkle == libbitcoin::hash_digest{0x7d, 0xac, 0x2c, 0x56, 0x66, 0x81, 0x5c, 0x17, 0xa3, 0xb3, 0x64, 0x27, 0xde, 0x37, 0xbb, 0x9d, 0x2e, 0x2c, 0x5c, 0xce, 0xc3, 0xf8, 0x63, 0x3e, 0xb9, 0x1a, 0x42, 0x05, 0xcb, 0x4c, 0x10, 0xff}));
}
示例9: inbound_channel_stopped
void protocol::inbound_channel_stopped(
const std::error_code& ec, channel_ptr which_node)
{
// We must always attempt a reconnection if this was an
// outbound connection.
if (ec)
{
log_error(LOG_PROTOCOL)
<< "Channel stopped (inbound): " << ec.message();
}
// Remove from accepted connections.
remove_channel(accepted_channels_, which_node);
}
示例10: succeeded
bool callback_state::succeeded(const std::error_code& code,
const std::string& format)
{
if (code)
{
// May want to change the behavior to decrement vs. zeroizing refs.
error(boost::format(format) % code.message());
stop(console_result::failure);
return false;
}
return true;
}
示例11: makeCurrentImpl
bool GlxContext::makeCurrentImpl(const GlSurface& surface, std::error_code& ec)
{
ec.clear();
auto drawable = dynamic_cast<const GlxSurface*>(&surface)->xDrawable();
if(!::glXMakeCurrent(xDisplay(), drawable, glxContext_))
{
//TODO: handle error into ec
warning("ny::GlxContext::makeCurrentImpl (glXMakeCurrent) failed");
return false;
}
return true;
}
示例12: handle_received_pkg
void net_tcp_connection_base::handle_received_pkg(const std::error_code &error, size_t bytes_transferred) {
if (!error) {
m_pEH->triger<tcp_recv_stream_succ>(this, bytes_transferred);
m_oRecvBuffer.filled() += bytes_transferred;
LOG(INFO) << "recv pkg: " << bytes_transferred << " bytes, from " << m_oRemoteEndpoint.address().to_string();
slice_and_dispatch_pkg();
start_recv();
} else {
m_iPointState = state_error;
LOG(WARNING) << "handle_received_pkg(), Get error " << error.message() << " from " <<
m_oRemoteEndpoint.address().to_string();
m_pEH->triger<tcp_recv_stream_error>(this, error);
}
}
示例13: connection_started
void fullnode::connection_started(const std::error_code& ec, channel_ptr node)
{
if (ec)
{
log_warning() << "Couldn't start connection: " << ec.message();
return;
}
// Subscribe to transaction messages from this node.
node->subscribe_transaction(
std::bind(&fullnode::recv_tx, this, _1, _2, node));
// Stay subscribed to new connections.
protocol_.subscribe_channel(
std::bind(&fullnode::connection_started, this, _1, _2));
}
示例14: json_history_fetched
void json_history_fetched(const payment_address& payaddr,
const std::error_code& ec, const blockchain::history_list& history)
{
if (ec)
{
std::cerr << "history: Failed to fetch history: "
<< ec.message() << std::endl;
return;
}
bool is_first = true;
for (const auto& row: history)
{
// Put commas between each array item in json output.
if (is_first)
is_first = false;
else
std::cout << "," << std::endl;
// Actual row data.
std::cout << "{" << std::endl;
std::cout << " \"address\": \"" << payaddr.encoded()
<< "\"," << std::endl;
std::cout << " \"output\": \"" << row.output
<< "\"," << std::endl;
std::cout << " \"output_height\": ";
if (!row.output_height)
std::cout << "\"Pending\"";
else
std::cout << row.output_height;
std::cout << "," << std::endl;
std::cout << " \"value\": \"" << row.value << "\"," << std::endl;
if (row.spend.hash == null_hash)
{
std::cout << " \"spend\": \"Unspent\"," << std::endl;
std::cout << " \"spend_height\": \"Unspent\"" << std::endl;
}
else
{
std::cout << " \"spend\": \"" << row.spend << "\"," << std::endl;
std::cout << " \"spend_height\": ";
if (!row.spend_height)
std::cout << "\"Pending\"";
else
std::cout << "\"" << row.spend_height << "\"";
}
std::cout << "}";
}
if (--remaining_count > 0)
std::cout << ",";
std::cout << std::endl;
}
示例15: monitor_tx
void server_node::monitor_tx(const std::error_code& ec, network::channel_ptr node)
{
if (ec)
{
log_warning(LOG_NODE) << "Couldn't start connection: " << ec.message();
return;
}
// Subscribe to transaction messages from this node.
node->subscribe_transaction(
std::bind(&server_node::recv_transaction, this, _1, _2, node));
// Stay subscribed to new connections.
protocol_.subscribe_channel(
std::bind(&server_node::monitor_tx, this, _1, _2));
}