mirror of
https://github.com/ankitects/anki.git
synced 2025-11-18 02:27:12 -05:00
23 lines
609 B
Rust
23 lines
609 B
Rust
pub use failure::{Error, Fail};
|
|
|
|
pub type Result<T> = std::result::Result<T, AnkiError>;
|
|
|
|
#[derive(Debug, Fail)]
|
|
pub enum AnkiError {
|
|
#[fail(display = "invalid input: {}", info)]
|
|
InvalidInput { info: String },
|
|
|
|
#[fail(display = "invalid card template: {}", info)]
|
|
TemplateParseError { info: String },
|
|
}
|
|
|
|
// error helpers
|
|
impl AnkiError {
|
|
pub(crate) fn parse<S: Into<String>>(s: S) -> AnkiError {
|
|
AnkiError::TemplateParseError { info: s.into() }
|
|
}
|
|
|
|
pub(crate) fn invalid_input<S: Into<String>>(s: S) -> AnkiError {
|
|
AnkiError::InvalidInput { info: s.into() }
|
|
}
|
|
}
|