File tree Expand file tree Collapse file tree 2 files changed +12
-9
lines changed Expand file tree Collapse file tree 2 files changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -41,7 +41,8 @@ class RPCClient {
4141 }
4242
4343 // blocking call
44- while (!get_response (msg_id_wait, result)){
44+ RpcError tmp_error;
45+ while (!get_response (msg_id_wait, result, tmp_error)) {
4546 // delay(1);
4647 }
4748
@@ -60,17 +61,14 @@ class RPCClient {
6061 }
6162
6263 template <typename RType>
63- bool get_response (const uint32_t wait_id, RType& result) {
64- RpcError tmp_error;
64+ bool get_response (const uint32_t wait_id, RType& result, RpcError& error) {
6565 decoder->decode ();
6666
67- if (decoder->get_response (wait_id, result, tmp_error)) {
68- lastError.code = tmp_error.code ;
69- lastError.traceback = tmp_error.traceback ;
67+ if (decoder->get_response (wait_id, result, error)) {
68+ lastError.copy (error);
7069 return true ;
71- } else if (tmp_error.code == PARSING_ERR) { // catches the parsing error
72- lastError.code = tmp_error.code ;
73- lastError.traceback = tmp_error.traceback ;
70+ } else if (error.code == PARSING_ERR) { // catches the parsing error
71+ lastError.copy (error);
7472 }
7573 return false ;
7674 }
Original file line number Diff line number Diff line change @@ -35,6 +35,11 @@ struct RpcError {
3535 RpcError (const int c, MsgPack::str_t tb)
3636 : code(c), traceback(std::move(tb)) {}
3737
38+ void copy (const RpcError& err) {
39+ code = err.code ;
40+ traceback = err.traceback ;
41+ }
42+
3843 MSGPACK_DEFINE (code, traceback); // -> [code, traceback]
3944};
4045
You can’t perform that action at this time.
0 commit comments