mirror of
https://github.com/zaaarf/fluent-fluently.git
synced 2024-11-22 09:44:49 +01:00
chore: error conversion implementation
This commit is contained in:
parent
0a759cfc29
commit
ecfe19f7e8
2 changed files with 15 additions and 11 deletions
22
src/error.rs
22
src/error.rs
|
@ -4,30 +4,34 @@ use fluent::FluentResource;
|
||||||
|
|
||||||
pub type Result<T> = StdResult<T, Error>;
|
pub type Result<T> = StdResult<T, Error>;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
IoError(String)
|
IoError(std::io::Error),
|
||||||
|
LanguageIdentifierError(unic_langid::LanguageIdentifierError),
|
||||||
|
FluentError(Vec<fluent::FluentError>)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<std::io::Error> for Error {
|
impl From<std::io::Error> for Error {
|
||||||
fn from(value: std::io::Error) -> Self {
|
fn from(err: std::io::Error) -> Self {
|
||||||
todo!()
|
Self::IoError(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<(FluentResource, Vec<fluent_syntax::parser::ParserError>)> for Error {
|
impl From<(FluentResource, Vec<fluent_syntax::parser::ParserError>)> for Error {
|
||||||
fn from(value: (FluentResource, Vec<fluent_syntax::parser::ParserError>)) -> Self {
|
fn from(err: (FluentResource, Vec<fluent_syntax::parser::ParserError>)) -> Self {
|
||||||
todo!()
|
let err = err.1.iter().map(|e| fluent::FluentError::ParserError(e.clone())).collect();
|
||||||
|
Self::FluentError(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Vec<fluent::FluentError>> for Error {
|
impl From<Vec<fluent::FluentError>> for Error {
|
||||||
fn from(value: Vec<fluent::FluentError>) -> Self {
|
fn from(err: Vec<fluent::FluentError>) -> Self {
|
||||||
todo!()
|
Self::FluentError(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<unic_langid::LanguageIdentifierError> for Error {
|
impl From<unic_langid::LanguageIdentifierError> for Error {
|
||||||
fn from(value: unic_langid::LanguageIdentifierError) -> Self {
|
fn from(err: unic_langid::LanguageIdentifierError) -> Self {
|
||||||
todo!()
|
Self::LanguageIdentifierError(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,8 @@ pub mod error;
|
||||||
|
|
||||||
type TypedFluentBundle = FluentBundle<Arc<FluentResource>, IntlLangMemoizer>;
|
type TypedFluentBundle = FluentBundle<Arc<FluentResource>, IntlLangMemoizer>;
|
||||||
pub struct Localiser {
|
pub struct Localiser {
|
||||||
bundles: HashMap<LanguageIdentifier, TypedFluentBundle>,
|
pub bundles: HashMap<LanguageIdentifier, TypedFluentBundle>,
|
||||||
default_language: LanguageIdentifier
|
pub default_language: LanguageIdentifier
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Localiser {
|
impl Localiser {
|
||||||
|
|
Loading…
Reference in a new issue