11#pragma once
22#include " client_util.hpp"
33#include " const_vars.h"
4+ #include " error_code.h"
45#include " md5.hpp"
56#include " meta_util.hpp"
67#include " use_asio.hpp"
@@ -292,7 +293,7 @@ class rpc_client : private asio::noncopyable {
292293 encoded_func_name_and_args.size ());
293294 write (fu_id, request_type::req_res, std::move (sbuffer),
294295 MD5::MD5Hash32 (encoded_func_name_and_args.data ()));
295- return fu_id;
296+ return ( long ) fu_id;
296297 }
297298
298299 template <typename R, size_t TIMEOUT = DEFAULT_TIMEOUT, typename ... Args>
@@ -553,9 +554,7 @@ class rpc_client : private asio::noncopyable {
553554
554555 if (!socket_.is_open ()) {
555556 // LOG(INFO) << "socket already closed";
556- call_back (req_id,
557- asio::error::make_error_code (asio::error::connection_aborted),
558- {});
557+ call_back (req_id, make_error_code (rpc_errc::socket_closed), {});
559558 return ;
560559 }
561560
@@ -567,8 +566,7 @@ class rpc_client : private asio::noncopyable {
567566 callback_sub (ec, {body_.data (), body_len});
568567 } else {
569568 close ();
570- error_callback (
571- asio::error::make_error_code (asio::error::invalid_argument));
569+ error_callback (make_error_code (rpc_errc::invalid_req_type));
572570 return ;
573571 }
574572
@@ -604,7 +602,7 @@ class rpc_client : private asio::noncopyable {
604602 // For Java client.
605603 // TODO(qwang): Call java callback.
606604 // handle error.
607- on_result_received_callback_ (req_id,
605+ on_result_received_callback_ (( long ) req_id,
608606 std::string (data.data (), data.size ()));
609607 } else {
610608 // For CPP client.
@@ -625,8 +623,7 @@ class rpc_client : private asio::noncopyable {
625623 cl->cancel ();
626624 cl->callback (ec, data);
627625 } else {
628- cl->callback (asio::error::make_error_code (asio::error::timed_out),
629- {});
626+ cl->callback (make_error_code (rpc_errc::request_timeout), {});
630627 }
631628
632629 std::unique_lock<std::mutex> lock (cb_mtx_);
@@ -670,8 +667,7 @@ class rpc_client : private asio::noncopyable {
670667
671668 it->second (data);
672669 } catch (const std::exception & /* ex*/ ) {
673- error_callback (
674- asio::error::make_error_code (asio::error::invalid_argument));
670+ error_callback (make_error_code (rpc_errc::function_exception));
675671 }
676672 }
677673
0 commit comments