Browse Source

Fail Electrum RPCs if daemon's RPC returns an error

It appears that bitcoind return "HTTP/1.1 500" in case of JSONRPC error:
63f8b0128b/src/httprpc.cpp (L72)
refactor-mempool
Roman Zeyde 7 years ago
parent
commit
38aa2a4cf4
No known key found for this signature in database GPG Key ID: 87CAE5FA46917CBB
  1. 15
      src/daemon.rs

15
src/daemon.rs

@ -212,15 +212,20 @@ impl Connection {
break;
}
}
if status == "HTTP/1.1 200 OK" {
contents.chain_err(|| ErrorKind::Connection("no reply from daemon".to_owned()))
contents
} else if status == "HTTP/1.1 500 Internal Server Error" {
warn!("HTTP status: {}", status);
contents // the contents should have a JSONRPC error field
} else {
let msg = format!(
bail!(
"request failed {:?}: {:?} = {:?}",
status, headers, contents
status,
headers,
contents
);
bail!(ErrorKind::Connection(msg));
}
}.chain_err(|| ErrorKind::Connection("no reply from daemon".to_owned()))
}
}

Loading…
Cancel
Save