From e09663181c1b16aace3d6d28410700549061cad6 Mon Sep 17 00:00:00 2001 From: who-biz <37732338+who-biz@users.noreply.github.com> Date: Wed, 20 Dec 2023 17:16:24 -0500 Subject: [PATCH 1/2] Change 'unwrap' usage to '?' operator --- controller/src/command.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/controller/src/command.rs b/controller/src/command.rs index 41d50b7a..de265200 100644 --- a/controller/src/command.rs +++ b/controller/src/command.rs @@ -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()?; } @@ -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); @@ -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); From 35584a7bef1104080b41097743e072249bd5fc84 Mon Sep 17 00:00:00 2001 From: who-biz <37732338+who-biz@users.noreply.github.com> Date: Wed, 20 Dec 2023 17:34:49 -0500 Subject: [PATCH 2/2] Revert a couple more ?->unwrap() changes --- impls/src/backends/lmdb.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/impls/src/backends/lmdb.rs b/impls/src/backends/lmdb.rs index 94852bab..71d3cf2f 100644 --- a/impls/src/backends/lmdb.rs +++ b/impls/src/backends/lmdb.rs @@ -588,8 +588,7 @@ where .borrow() .as_ref() .unwrap() - .put_ser(&key, Serializable::OutputData(out)) - .unwrap(); + .put_ser(&key, Serializable::OutputData(out))?; } Ok(()) @@ -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(()) }