Tabbing now works, impelemented preliminary error message handling
This commit is contained in:
@@ -102,7 +102,7 @@ pub fn search_for_word(word: &str, from_files: &Bible) -> Vec<String> {
|
||||
found
|
||||
}
|
||||
|
||||
pub fn get(book: &str, chap_and_ver: &str, bibles: Vec<&Bible>) -> Option<String> {
|
||||
pub fn get(book: &str, chap_and_ver: &str, bibles: Vec<&Bible>) -> Result<String, String> {
|
||||
// expecting query to be in format:
|
||||
// Gen 1:2
|
||||
// Gen 1:2-5
|
||||
@@ -135,11 +135,11 @@ pub fn get(book: &str, chap_and_ver: &str, bibles: Vec<&Bible>) -> Option<String
|
||||
for (_, i) in &res {
|
||||
eprintln!("\t{i}");
|
||||
}
|
||||
return None;
|
||||
return Err(format!("Ambigious input '{book}'"));
|
||||
}
|
||||
_ => {
|
||||
eprintln!("'{book}' is not a book");
|
||||
return None;
|
||||
return Err(format!("'{book}' is not a book"));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -162,10 +162,10 @@ pub fn get(book: &str, chap_and_ver: &str, bibles: Vec<&Bible>) -> Option<String
|
||||
.map(|(bible,book,chapter)| (*bible,*book,chapter.unwrap()))
|
||||
.collect::<Vec<(&Bible, &Book, &Chapter)>>()
|
||||
} else {
|
||||
return None;
|
||||
return Err(format!("Chapter number could not be parsed from {chapter}"));
|
||||
}
|
||||
} else {
|
||||
return None;
|
||||
return Err(format!("A chapter was not passed"));
|
||||
};
|
||||
|
||||
// Get the verse in each Bible
|
||||
@@ -190,9 +190,9 @@ pub fn get(book: &str, chap_and_ver: &str, bibles: Vec<&Bible>) -> Option<String
|
||||
}
|
||||
}
|
||||
}
|
||||
return Some(buf);
|
||||
return Ok(buf);
|
||||
}
|
||||
return None;
|
||||
return Err(format!("Could not parse '{sn}' or '{en}' into numbers"));
|
||||
}
|
||||
// only one verse
|
||||
(Some(ver_num), None) => {
|
||||
@@ -206,13 +206,13 @@ pub fn get(book: &str, chap_and_ver: &str, bibles: Vec<&Bible>) -> Option<String
|
||||
);
|
||||
}
|
||||
}
|
||||
return Some(buf);
|
||||
return Ok(buf);
|
||||
}
|
||||
return None;
|
||||
return Err(format!("Could not parse '{ver_num}' into a number"));
|
||||
}
|
||||
_ => {
|
||||
// couldn't parse verse
|
||||
return None;
|
||||
return Err(format!("Couldn't parse '{:?}' or '{:?}' into verse numbers", start, end));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -226,7 +226,7 @@ pub fn get(book: &str, chap_and_ver: &str, bibles: Vec<&Bible>) -> Option<String
|
||||
);
|
||||
buf += &format!("{}", chapter);
|
||||
}
|
||||
return Some(buf);
|
||||
return Ok(buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user