ens_normalize_rs/
error.rs1use crate::CodePoint;
2
3#[derive(Debug, Clone, thiserror::Error, PartialEq, Eq)]
4pub enum ProcessError {
5 #[error("contains visually confusing characters from multiple scripts: {0}")]
6 Confused(String),
7 #[error("contains visually confusing characters from {group1} and {group2} scripts")]
8 ConfusedGroups { group1: String, group2: String },
9 #[error("invalid character ('{sequence}') at position {index}: {inner}")]
10 CurrableError {
11 inner: CurrableError,
12 index: usize,
13 sequence: String,
14 maybe_suggest: Option<String>,
15 },
16 #[error("disallowed sequence: {0}")]
17 DisallowedSequence(#[from] DisallowedSequence),
18}
19
20#[derive(Debug, Clone, thiserror::Error, PartialEq, Eq)]
21pub enum CurrableError {
22 #[error("underscore in middle")]
23 UnderscoreInMiddle,
24 #[error("hyphen at second and third position")]
25 HyphenAtSecondAndThird,
26 #[error("combining mark in disallowed position at the start of the label")]
27 CmStart,
28 #[error("combining mark in disallowed position after an emoji")]
29 CmAfterEmoji,
30 #[error("fenced character at the start of a label")]
31 FencedLeading,
32 #[error("fenced character at the end of a label")]
33 FencedTrailing,
34 #[error("consecutive sequence of fenced characters")]
35 FencedConsecutive,
36}
37
38#[derive(Debug, Clone, thiserror::Error, PartialEq, Eq)]
39pub enum DisallowedSequence {
40 #[error("disallowed character: {0}")]
41 Invalid(String),
42 #[error("invisible character: {0}")]
43 InvisibleCharacter(CodePoint),
44 #[error("empty label")]
45 EmptyLabel,
46 #[error("nsm too many")]
47 NsmTooMany,
48 #[error("nsm repeated")]
49 NsmRepeated,
50}