mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-07 07:18:03 +00:00
Don’t panic on storage decode error (#30)
Instead of panicking when the storage data reveived cannot be decoded we pass on the error.
This commit is contained in:
committed by
Andrew Jones
parent
04c371b32c
commit
5c2eeee1d2
+9
-3
@@ -86,10 +86,16 @@ impl<T: System> Rpc<T> {
|
||||
) -> impl Future<Item = Option<V>, Error = Error> {
|
||||
self.state
|
||||
.storage(key, None)
|
||||
.map(|data| {
|
||||
data.map(|d| Decode::decode(&mut &d.0[..]).expect("Valid storage key"))
|
||||
})
|
||||
.map_err(Into::into)
|
||||
.and_then(|data| {
|
||||
match data {
|
||||
Some(data) => {
|
||||
let value = Decode::decode(&mut &data.0[..])?;
|
||||
Ok(Some(value))
|
||||
}
|
||||
None => Ok(None),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/// Fetch the genesis hash
|
||||
|
||||
Reference in New Issue
Block a user