Skip to content

Commit a82ded9

Browse files
authored
Update readme to use ? instead of unwrap (#32)
* Update readme to use ? instead of unwrap
1 parent f24cca7 commit a82ded9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pyth-sdk-terra/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ For reading the price you just need to call `query_price_feed` function within y
1414
You can find the contract address and price feed ids in the section [Contracts and Price Feeds](#contracts-and-price-feeds) below.
1515

1616
```rust
17-
let price_feed: PriceFeed = query_price_feed(deps.querier, contract_addr, id).unwrap().price_feed;
17+
let price_feed: PriceFeed = query_price_feed(deps.querier, contract_addr, id)?.price_feed;
1818
```
1919

2020
The `PriceFeed` struct contains several useful functions for working with the price.
@@ -27,7 +27,7 @@ For more detailed information, please see the crate documentation.
2727
Read the current price from a `PriceFeed`:
2828

2929
```rust
30-
let current_price: Price = price_feed.get_current_price().unwrap();
30+
let current_price: Price = price_feed.get_current_price().ok_or(StdError::not_found("Current Price is not available"))?;
3131
println!("price: ({} +- {}) x 10^{}", current_price.price, current_price.conf, current_price.expo);
3232
```
3333

0 commit comments

Comments
 (0)