Skip to content

Commit 9fc4d6f

Browse files
Return error instead of panicking
1 parent 52f0b14 commit 9fc4d6f

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/adder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub fn handle_add(doc: &mut DocumentMut, op: AddOp) -> Result<()> {
4545
}
4646
None => {
4747
let mut path_split = path
48-
.expect("Missing 'path' value")
48+
.context("Missing 'path' value")?
4949
.split('/')
5050
.map(|s| s.to_string())
5151
.collect::<Vec<String>>();

src/adder/table_header_adder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use anyhow::{bail, Result};
1+
use anyhow::{bail, Context, Result};
22
use toml_edit::{array, Item, Table, Value};
33

44
/*
@@ -24,7 +24,7 @@ pub fn add_value_with_table_header_and_dotted_path(
2424
None => {
2525
add_value_with_dotted_path(
2626
table,
27-
dotted_path.expect("Missing 'path' value").as_slice(),
27+
dotted_path.context("Missing 'path' value")?.as_slice(),
2828
value,
2929
)?;
3030
Ok(())

0 commit comments

Comments
 (0)