Rewrite external linking handler function to use less unwrap()
This commit is contained in:
parent
b90dabaa97
commit
ec9710f1e7
1 changed files with 8 additions and 10 deletions
|
@ -213,16 +213,14 @@ fn get_entry_by_name<'a>(rt: &'a Runtime, name: &str) -> Result<Option<FileLockE
|
||||||
fn handle_external_linking(rt: &Runtime) {
|
fn handle_external_linking(rt: &Runtime) {
|
||||||
let scmd = rt.cli().subcommand_matches("external").unwrap();
|
let scmd = rt.cli().subcommand_matches("external").unwrap();
|
||||||
let entry_name = scmd.value_of("id").unwrap(); // enforced by clap
|
let entry_name = scmd.value_of("id").unwrap(); // enforced by clap
|
||||||
let entry = get_entry_by_name(rt, entry_name);
|
let mut entry = match get_entry_by_name(rt, entry_name) {
|
||||||
if entry.is_err() {
|
Err(e) => trace_error_exit(&e, 1),
|
||||||
trace_error_exit(&entry.unwrap_err(), 1);
|
Ok(None) => {
|
||||||
}
|
warn!("Entry not found: {:?}", entry_name);
|
||||||
let entry = entry.unwrap();
|
return;
|
||||||
if entry.is_none() {
|
},
|
||||||
warn!("Entry not found: {:?}", entry_name);
|
Ok(Some(entry)) => entry
|
||||||
return;
|
};
|
||||||
}
|
|
||||||
let mut entry = entry.unwrap();
|
|
||||||
|
|
||||||
if scmd.is_present("add") {
|
if scmd.is_present("add") {
|
||||||
debug!("Adding link to entry!");
|
debug!("Adding link to entry!");
|
||||||
|
|
Loading…
Reference in a new issue