[librsvg: 16/23] impl Error for AcceptLanguageError
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 16/23] impl Error for AcceptLanguageError
- Date: Mon, 24 May 2021 17:47:32 +0000 (UTC)
commit 41edfce2e70a3868abb18b97a074d6d345c8df15
Author: Federico Mena Quintero <federico gnome org>
Date: Fri May 21 19:56:28 2021 -0500
impl Error for AcceptLanguageError
src/accept_language.rs | 15 +++++++++++++++
1 file changed, 15 insertions(+)
---
diff --git a/src/accept_language.rs b/src/accept_language.rs
index b6e85c05..545dfea7 100644
--- a/src/accept_language.rs
+++ b/src/accept_language.rs
@@ -3,6 +3,8 @@
use language_tags::{LanguageTag, ParseError};
use locale_config::{LanguageRange, Locale};
+use std::error;
+use std::fmt;
use std::str::FromStr;
/// Used to set the language for rendering.
@@ -59,6 +61,19 @@ pub enum AcceptLanguageError {
InvalidWeight,
}
+impl error::Error for AcceptLanguageError {}
+
+impl fmt::Display for AcceptLanguageError {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ match self {
+ Self::NoElements => write!(f, "no language tags in list"),
+ Self::InvalidCharacters => write!(f, "invalid characters in language list"),
+ Self::InvalidLanguageTag(e) => write!(f, "invalid language tag: {}", e),
+ Self::InvalidWeight => write!(f, "invalid q= weight"),
+ }
+ }
+}
+
/// Optional whitespace, Space or Tab, per https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.3
const OWS: [char; 2] = ['\x20', '\x09'];
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]