Skip to content

Commit

Permalink
Improve error propagation
Browse files Browse the repository at this point in the history
  • Loading branch information
xla committed Jul 7, 2020
1 parent c98be58 commit 881d831
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion light-node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jsonrpc-core-client = "14.2"
jsonrpc-http-server = "14.2"
jsonrpc-derive = "14.2"
serde = { version = "1", features = ["serde_derive"] }
serde_json = "1.0"
tendermint = { version = "0.14.0", path = "../tendermint" }
tendermint-light-client = { version = "0.14.0", path = "../light-client" }
tendermint-rpc = { version = "0.14.0", path = "../rpc", features = [ "client" ] }
Expand All @@ -32,4 +33,3 @@ abscissa_core = { version = "0.5.0", features = ["testing"] }
futures = { version = "0.3", features = [ "compat" ] }
once_cell = "1.2"
pretty_assertions = "0.6"
serde_json = "1.0"
10 changes: 6 additions & 4 deletions light-node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,12 @@ mod sealed {
H: Handle + Send + Sync + 'static,
{
fn state(&self) -> FutureResult<Option<LightBlock>, Error> {
let res = self
.handle
.latest_trusted()
.map_err(|_e| Error::internal_error());
let res = self.handle.latest_trusted().map_err(|e| {
let mut err = Error::internal_error();
err.message = e.to_string();
err.data = serde_json::to_value(e.kind()).ok();
err
});

future::result(res)
}
Expand Down

0 comments on commit 881d831

Please sign in to comment.