diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2023-08-02 14:45:48 +0200 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2023-08-03 08:36:51 +0200 |
| commit | e7c35a551fe870631c0d1dabc0458c82792eec7b (patch) | |
| tree | 45a49f0842b2c537dd72c8a7d3c19ed3e9440c4e /android | |
| parent | 055fadd99d985285b59537bca1477ea4eb4a2ebd (diff) | |
| download | mullvadvpn-e7c35a551fe870631c0d1dabc0458c82792eec7b.tar.xz mullvadvpn-e7c35a551fe870631c0d1dabc0458c82792eec7b.zip | |
Migrate translation-converter to err_derive
Diffstat (limited to 'android')
4 files changed, 28 insertions, 25 deletions
diff --git a/android/translations-converter/Cargo.toml b/android/translations-converter/Cargo.toml index dc7f1272d1..938f7503d8 100644 --- a/android/translations-converter/Cargo.toml +++ b/android/translations-converter/Cargo.toml @@ -9,7 +9,7 @@ edition.workspace = true publish.workspace = true [dependencies] -derive_more = "0.99" +err-derive = "0.3.1" htmlize = { version = "1.0.2", features = ["unescape"] } lazy_static = "1" regex = "1" diff --git a/android/translations-converter/src/gettext/messages.rs b/android/translations-converter/src/gettext/messages.rs index c8a29bd734..e9dc151bfc 100644 --- a/android/translations-converter/src/gettext/messages.rs +++ b/android/translations-converter/src/gettext/messages.rs @@ -1,5 +1,4 @@ use super::{msg_string::MsgString, parser::Parser, plural_form::PluralForm}; -use derive_more::{Display, Error, From}; use std::{ fs::File, io::{BufRead, BufReader}, @@ -104,13 +103,13 @@ impl From<MsgString> for MsgValue { } } -#[derive(Debug, Display, Error, From)] +#[derive(Debug, err_derive::Error)] pub enum Error { /// Parser error while parsing file - #[display(fmt = "Failed to parse input file")] - Parse(super::parser::Error), + #[error(display = "Failed to parse input file")] + Parse(#[error(source)] super::parser::Error), /// IO error while reading input file. - #[display(fmt = "Failed to read from the input file")] - Io(std::io::Error), + #[error(display = "Failed to read from the input file")] + Io(#[error(source)] std::io::Error), } diff --git a/android/translations-converter/src/gettext/parser.rs b/android/translations-converter/src/gettext/parser.rs index 609ba38122..177f15d15a 100644 --- a/android/translations-converter/src/gettext/parser.rs +++ b/android/translations-converter/src/gettext/parser.rs @@ -1,5 +1,4 @@ use super::{Messages, MsgString, PluralForm}; -use derive_more::{Display, Error}; use std::{collections::BTreeMap, mem}; /// A gettext messages file parser. @@ -527,29 +526,35 @@ fn collect_variants( } /// Parsing errors. -#[derive(Clone, Debug, Display, Error, Eq, PartialEq)] +#[derive(Clone, Debug, Eq, PartialEq, err_derive::Error)] pub enum Error { /// An unexpected line was read while parsing. - #[display(fmt = "Unexpected line parsing gettext messages: {_0}")] - UnexpectedLine(#[error(not(source))] String), + #[error(display = "Unexpected line parsing gettext messages: {}", _0)] + UnexpectedLine(String), /// Input uses an unrecognized plural forumal. - #[display(fmt = "Input uses an unrecognized formula for the plural form: {_0}")] - UnrecognizedPluralFormula(#[error(not(source))] String), + #[error( + display = "Input uses an unrecognized formula for the plural form: {}", + _0 + )] + UnrecognizedPluralFormula(String), /// Input ended with an incomplete entry. - #[display(fmt = "Input ended with an incomplete gettext entry with ID: {_0}")] - IncompleteEntry(#[error(not(source))] MsgString), + #[error( + display = "Input ended with an incomplete gettext entry with ID: {}", + _0 + )] + IncompleteEntry(MsgString), /// Plural entry definition is missing a plural variant. - #[display(fmt = "Plural entry is missing a plural variant: {_0}")] - IncompletePluralEntry(#[error(not(source))] MsgString), + #[error(display = "Plural entry is missing a plural variant: {}", _0)] + IncompletePluralEntry(MsgString), /// Plural variant is invalid. - #[display(fmt = "Plural variant line is invalid: {_0}")] - InvalidPluralVariant(#[error(not(source))] String), + #[error(display = "Plural variant line is invalid: {}", _0)] + InvalidPluralVariant(String), /// Plural variant index was not parsable. - #[display(fmt = "Plural variant line contains an invalid index: {_0}")] - InvalidPluralIndex(#[error(not(source))] String), + #[error(display = "Plural variant line contains an invalid index: {}", _0)] + InvalidPluralIndex(String), } diff --git a/android/translations-converter/src/gettext/plural_form.rs b/android/translations-converter/src/gettext/plural_form.rs index abd1ae7d46..6d3436b8c2 100644 --- a/android/translations-converter/src/gettext/plural_form.rs +++ b/android/translations-converter/src/gettext/plural_form.rs @@ -1,4 +1,3 @@ -use derive_more::{Display, Error}; use std::str::FromStr; /// Known plural forms. @@ -45,6 +44,6 @@ impl FromStr for PluralForm { /// Failed to create [`PluralForm`] from specified plural formula. /// /// The formula could be an invalid formula, or support for it hasn't been added yet. -#[derive(Clone, Debug, Display, Error)] -#[display(fmt = "Unsupported plural formula: {_0}")] -pub struct UnsupportedPluralFormulaError(#[error(not(source))] String); +#[derive(Clone, Debug, err_derive::Error)] +#[error(display = "Unsupported plural formula: {}", _0)] +pub struct UnsupportedPluralFormulaError(String); |
