bible_lib/
error.rs

1use std::fmt::{Display, Formatter};
2
3
4/// Errors that can occur in the Bible Lib
5pub enum BibleLibError {
6    /// The specified custom translation file is invalid or does not exist.
7    InvalidCustomTranslationFile,
8    /// The specified verse was not found in the translation.
9    VerseNotFound,
10    /// The specified chapter was not found in the translation.
11    ChapterNotFound,
12    /// The specified book was not found in the translation.
13    BookNotFound,
14    /// The verse format provided is invalid.
15    InvalidVerseFormat,
16    /// An I/O error occurred.
17    IOError(std::io::Error),
18}
19
20impl Display for BibleLibError {
21    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
22        match self {
23            BibleLibError::InvalidCustomTranslationFile => {
24                write!(f, "The specified custom translation file is invalid or does not exist.")
25            }
26            BibleLibError::VerseNotFound => {
27                write!(f, "The specified verse was not found in the translation.")
28            }
29            BibleLibError::ChapterNotFound => {
30                write!(f, "The specified chapter was not found in the translation.")
31            }
32            BibleLibError::BookNotFound => {
33                write!(f, "The specified book was not found in the translation.")
34            }
35            BibleLibError::InvalidVerseFormat => {
36                write!(f, "The verse format provided is invalid.")
37            }
38            BibleLibError::IOError(e) => {
39                write!(f, "An I/O error occurred: {}", e)
40            }
41        }
42    }
43}