X-Git-Url: http://these/git/?a=blobdiff_plain;f=crates%2Futils%2Fsrc%2Futils%2Fslurs.rs;h=cc2d6a3e6eb0772e67ab9a1a691f3cc3c9541fa4;hb=92568956353f21649ed9aff68b42699c9d036f30;hp=b92650ea31375bbf6bef0480c534e2e2249931e9;hpb=36aaa5064400e794ffc4141dcadca6f75d1978db;p=lemmy.git diff --git a/crates/utils/src/utils/slurs.rs b/crates/utils/src/utils/slurs.rs index b92650ea..cc2d6a3e 100644 --- a/crates/utils/src/utils/slurs.rs +++ b/crates/utils/src/utils/slurs.rs @@ -1,4 +1,4 @@ -use crate::error::LemmyError; +use crate::error::{LemmyError, LemmyErrorExt, LemmyErrorType}; use regex::{Regex, RegexBuilder}; pub fn remove_slurs(test: &str, slur_regex: &Option) -> String { @@ -41,10 +41,7 @@ pub fn build_slur_regex(regex_str: Option<&str>) -> Option { pub fn check_slurs(text: &str, slur_regex: &Option) -> Result<(), LemmyError> { if let Err(slurs) = slur_check(text, slur_regex) { - Err(LemmyError::from_error_message( - anyhow::anyhow!("{}", slurs_vec_to_str(&slurs)), - "slurs", - )) + Err(anyhow::anyhow!("{}", slurs_vec_to_str(&slurs))).with_lemmy_type(LemmyErrorType::Slurs) } else { Ok(()) } @@ -68,6 +65,9 @@ pub(crate) fn slurs_vec_to_str(slurs: &[&str]) -> String { #[cfg(test)] mod test { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::utils::slurs::{remove_slurs, slur_check, slurs_vec_to_str}; use regex::RegexBuilder;