]> Untitled Git - lemmy.git/blobdiff - crates/utils/src/utils.rs
Rework error handling (fixes #1714) (#2135)
[lemmy.git] / crates / utils / src / utils.rs
index a1fefffe84a3ff958956b3c57012e7877774b71b..f9c68f4ef6db08f36d2608655b2d36f02c08a557 100644 (file)
@@ -62,8 +62,10 @@ pub(crate) fn slur_check<'a>(
 
 pub fn check_slurs(text: &str, slur_regex: &Option<Regex>) -> Result<(), LemmyError> {
   if let Err(slurs) = slur_check(text, slur_regex) {
-    let error = LemmyError::from(anyhow::anyhow!("{}", slurs_vec_to_str(slurs)));
-    Err(error.with_message("slurs"))
+    Err(LemmyError::from_error_message(
+      anyhow::anyhow!("{}", slurs_vec_to_str(slurs)),
+      "slurs",
+    ))
   } else {
     Ok(())
   }