summaryrefslogtreecommitdiffhomepage
path: root/android
diff options
context:
space:
mode:
authorJoakim Hulthe <joakim@hulthe.net>2024-02-26 14:24:15 +0100
committerDavid Lönnhager <david.l@mullvad.net>2024-02-27 10:38:19 +0100
commita6d3578d256349ffe74b7c6a7a80ac2d70b7f68e (patch)
tree92d6bfab07a4d7d8d88fce7680ffd8278c37d4ce /android
parent0a4915b113263f8353663e4fc07297d2862f2bc0 (diff)
downloadmullvadvpn-a6d3578d256349ffe74b7c6a7a80ac2d70b7f68e.tar.xz
mullvadvpn-a6d3578d256349ffe74b7c6a7a80ac2d70b7f68e.zip
Replace err_derive with thiserror
`err_derive` is unmaintained and will probably stop working with rust edition 2024. `thiserror` is almost a drop-in replacement. This commit simply replaces all occurences of `derive(err_derive::Error)` with `derive(thiserror::Error)` and fixes the attributes, but the Error and Display impls should be identical.
Diffstat (limited to 'android')
-rw-r--r--android/translations-converter/Cargo.toml2
-rw-r--r--android/translations-converter/src/gettext/messages.rs10
-rw-r--r--android/translations-converter/src/gettext/parser.rs20
-rw-r--r--android/translations-converter/src/gettext/plural_form.rs4
4 files changed, 15 insertions, 21 deletions
diff --git a/android/translations-converter/Cargo.toml b/android/translations-converter/Cargo.toml
index 3629b7372f..57deb26a57 100644
--- a/android/translations-converter/Cargo.toml
+++ b/android/translations-converter/Cargo.toml
@@ -11,7 +11,7 @@ rust-version.workspace = true
workspace = true
[dependencies]
-err-derive = { workspace = true }
+thiserror = { workspace = true }
htmlize = { version = "1.0.2", features = ["unescape"] }
once_cell = { workspace = true }
regex = "1"
diff --git a/android/translations-converter/src/gettext/messages.rs b/android/translations-converter/src/gettext/messages.rs
index e9dc151bfc..25316afae4 100644
--- a/android/translations-converter/src/gettext/messages.rs
+++ b/android/translations-converter/src/gettext/messages.rs
@@ -103,13 +103,13 @@ impl From<MsgString> for MsgValue {
}
}
-#[derive(Debug, err_derive::Error)]
+#[derive(Debug, thiserror::Error)]
pub enum Error {
/// Parser error while parsing file
- #[error(display = "Failed to parse input file")]
- Parse(#[error(source)] super::parser::Error),
+ #[error("Failed to parse input file")]
+ Parse(#[from] super::parser::Error),
/// IO error while reading input file.
- #[error(display = "Failed to read from the input file")]
- Io(#[error(source)] std::io::Error),
+ #[error("Failed to read from the input file")]
+ Io(#[from] std::io::Error),
}
diff --git a/android/translations-converter/src/gettext/parser.rs b/android/translations-converter/src/gettext/parser.rs
index 177f15d15a..4d1928b473 100644
--- a/android/translations-converter/src/gettext/parser.rs
+++ b/android/translations-converter/src/gettext/parser.rs
@@ -526,35 +526,29 @@ fn collect_variants(
}
/// Parsing errors.
-#[derive(Clone, Debug, Eq, PartialEq, err_derive::Error)]
+#[derive(Clone, Debug, Eq, PartialEq, thiserror::Error)]
pub enum Error {
/// An unexpected line was read while parsing.
- #[error(display = "Unexpected line parsing gettext messages: {}", _0)]
+ #[error("Unexpected line parsing gettext messages: {0}")]
UnexpectedLine(String),
/// Input uses an unrecognized plural forumal.
- #[error(
- display = "Input uses an unrecognized formula for the plural form: {}",
- _0
- )]
+ #[error("Input uses an unrecognized formula for the plural form: {0}")]
UnrecognizedPluralFormula(String),
/// Input ended with an incomplete entry.
- #[error(
- display = "Input ended with an incomplete gettext entry with ID: {}",
- _0
- )]
+ #[error("Input ended with an incomplete gettext entry with ID: {0}")]
IncompleteEntry(MsgString),
/// Plural entry definition is missing a plural variant.
- #[error(display = "Plural entry is missing a plural variant: {}", _0)]
+ #[error("Plural entry is missing a plural variant: {0}")]
IncompletePluralEntry(MsgString),
/// Plural variant is invalid.
- #[error(display = "Plural variant line is invalid: {}", _0)]
+ #[error("Plural variant line is invalid: {0}")]
InvalidPluralVariant(String),
/// Plural variant index was not parsable.
- #[error(display = "Plural variant line contains an invalid index: {}", _0)]
+ #[error("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 6d3436b8c2..7eac7de0d6 100644
--- a/android/translations-converter/src/gettext/plural_form.rs
+++ b/android/translations-converter/src/gettext/plural_form.rs
@@ -44,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, err_derive::Error)]
-#[error(display = "Unsupported plural formula: {}", _0)]
+#[derive(Clone, Debug, thiserror::Error)]
+#[error("Unsupported plural formula: {0}")]
pub struct UnsupportedPluralFormulaError(String);