Skip to content

Commit

Permalink
Merge pull request #104 from who-biz/controller-dont-use-unwrap
Browse files Browse the repository at this point in the history
Change 'unwrap' usage to '?' operator in controller/src/command.rs
  • Loading branch information
johanneshahn committed Dec 22, 2023
2 parents 0fce73c + 35584a7 commit e537e02
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
6 changes: 3 additions & 3 deletions controller/src/command.rs
Expand Up @@ -448,7 +448,7 @@ where
let method = args.method.as_str();
let mut slate;
if method == "emoji" {
slate = EmojiSlate().decode(&args.input.as_str()).unwrap();
slate = EmojiSlate().decode(&args.input.as_str())?;
} else {
slate = PathToSlate((&args.input).into()).get_tx()?;
}
Expand Down Expand Up @@ -889,7 +889,7 @@ where
return Ok(());
}
Some(f) => {
let mut tx_file = File::create(f.clone()).unwrap();
let mut tx_file = File::create(f.clone())?;
tx_file.write_all(json::to_string(&stored_tx).unwrap().as_bytes())?;
tx_file.sync_all()?;
info!("Dumped transaction data for tx {} to {}", args.id, f);
Expand Down Expand Up @@ -1038,7 +1038,7 @@ where
match result {
Ok(p) => {
// actually export proof
let mut proof_file = File::create(args.output_file.clone()).unwrap();
let mut proof_file = File::create(args.output_file.clone())?;
proof_file.write_all(json::to_string_pretty(&p).unwrap().as_bytes())?;
proof_file.sync_all()?;
warn!("Payment proof exported to {}", args.output_file);
Expand Down
6 changes: 2 additions & 4 deletions impls/src/backends/lmdb.rs
Expand Up @@ -588,8 +588,7 @@ where
.borrow()
.as_ref()
.unwrap()
.put_ser(&key, Serializable::OutputData(out))
.unwrap();
.put_ser(&key, Serializable::OutputData(out))?;
}

Ok(())
Expand Down Expand Up @@ -817,8 +816,7 @@ where
.borrow()
.as_ref()
.unwrap()
.put_ser(&tx_log_key, Serializable::TxLogEntry(tx_in))
.unwrap();
.put_ser(&tx_log_key, Serializable::TxLogEntry(tx_in))?;
Ok(())
}

Expand Down

0 comments on commit e537e02

Please sign in to comment.