blob: a777a8b723146c7bf9b853f619082fb672784122 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
use std::result::Result as StdResult;
use fluent::FluentResource;
pub type Result<T> = StdResult<T, Error>;
/// Simple wrapper around the errors that may occur during the program's execution.
#[derive(Debug)]
pub enum Error {
GenericError(String),
IoError(std::io::Error),
LanguageIdentifierError(unic_langid::LanguageIdentifierError),
FluentError(Vec<fluent::FluentError>),
MissingMessageError(String)
}
impl From<std::io::Error> for Error {
fn from(err: std::io::Error) -> Self {
Self::IoError(err)
}
}
impl From<(FluentResource, Vec<fluent_syntax::parser::ParserError>)> for Error {
fn from(err: (FluentResource, Vec<fluent_syntax::parser::ParserError>)) -> Self {
let err = err.1.iter().map(|e| fluent::FluentError::ParserError(e.clone())).collect();
Self::FluentError(err)
}
}
impl From<Vec<fluent::FluentError>> for Error {
fn from(err: Vec<fluent::FluentError>) -> Self {
Self::FluentError(err)
}
}
impl From<unic_langid::LanguageIdentifierError> for Error {
fn from(err: unic_langid::LanguageIdentifierError) -> Self {
Self::LanguageIdentifierError(err)
}
}
|