Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix cargo test
  • Loading branch information
sevenzing committed Dec 5, 2024
commit 0784b0ef263b86d18d598d33293a396690a3d439
2 changes: 2 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ pub enum CurrableError {
FencedConsecutive,
#[error("contains visually confusing characters from multiple scripts: character with code '{cp}' not in group '{group_name}'")]
Confused { group_name: String, cp: CodePoint },
#[error("contains a disallowed character")]
Disallowed,
}

/// Errors regarding disallowed sequences.
Expand Down
29 changes: 14 additions & 15 deletions src/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,23 +342,22 @@ fn determine_group<'a>(
.iter_cps()
.position(|cp_in_label| cp_in_label == cp)
.expect("cp must exist in label");
match maybe_group {
Some(group) => {
return Err(ProcessError::CurrableError {
inner: CurrableError::Confused {
group_name: group.name.to_string(),
cp,
},
index: index_of_cp,
sequence: utils::cp2str(cp),
maybe_suggest: Some("".to_string()),
});
}
None => unreachable!(),
}
let inner = match maybe_group {
Some(group) => CurrableError::Confused {
group_name: group.name.to_string(),
cp,
},
None => CurrableError::Disallowed,
};
return Err(ProcessError::CurrableError {
inner,
index: index_of_cp,
sequence: utils::cp2str(cp),
maybe_suggest: Some("".to_string()),
});
}
}
unreachable!("")
unreachable!()
}
}

Expand Down
Loading