File tree Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change 16
16
#include < jsoncpp/json/json.h>
17
17
#include < jsoncpp/json/reader.h>
18
18
#include < jsoncpp/json/value.h>
19
+ #include < jsonrpccpp/client.h>
19
20
20
21
using Json::Value;
21
22
using Json::Reader;
23
+ using jsonrpc::Errors;
22
24
23
25
24
26
class BitcoinException : public std ::exception
@@ -29,9 +31,22 @@ class BitcoinException: public std::exception
29
31
30
32
public:
31
33
explicit BitcoinException (int errcode, const std::string& message) {
32
- this ->code = parseCode (message);
33
- this ->msg = parseMessage (message);
34
+
35
+ /* Connection error */
36
+ if (errcode == Errors::ERROR_CLIENT_CONNECTOR){
37
+ this ->code = errcode;
38
+ this ->msg = removePrefix (message, " -> " );
39
+ /* Authentication error */
40
+ }else if (errcode == Errors::ERROR_RPC_INTERNAL_ERROR && message.size () == 18 ){
41
+ this ->code = errcode;
42
+ this ->msg = " Failed to authenticate successfully" ;
43
+ /* Miscellaneous error */
44
+ }else {
45
+ this ->code = parseCode (message);
46
+ this ->msg = parseMessage (message);
47
+ }
34
48
}
49
+
35
50
~BitcoinException () throw () { };
36
51
37
52
int getCode (){
@@ -55,7 +70,7 @@ class BitcoinException: public std::exception
55
70
return ret;
56
71
}
57
72
58
-
73
+ /* Auxiliary JSON parsing */
59
74
int parseCode (const std::string& in){
60
75
Value root;
61
76
Reader reader;
You can’t perform that action at this time.
0 commit comments