]> Untitled Git - lemmy.git/blobdiff - crates/utils/src/rate_limit/rate_limiter.rs
Rework error handling (fixes #1714) (#2135)
[lemmy.git] / crates / utils / src / rate_limit / rate_limiter.rs
index 580ed3e7de137d3b9d6bfd80b9b1559b1d2e5d0d..75b7808d3dede22fd1a056bf337dc423c4cb4457 100644 (file)
@@ -79,14 +79,16 @@ impl RateLimiter {
             time_passed,
             rate_limit.allowance
           );
-          let error = LemmyError::from(anyhow::anyhow!(
-            "Too many requests. type: {}, IP: {}, {} per {} seconds",
-            type_.as_ref(),
-            ip,
-            rate,
-            per
-          ));
-          Err(error.with_message("too_many_requests"))
+          Err(LemmyError::from_error_message(
+            anyhow::anyhow!(
+              "Too many requests. type: {}, IP: {}, {} per {} seconds",
+              type_.as_ref(),
+              ip,
+              rate,
+              per
+            ),
+            "too_many_requests",
+          ))
         } else {
           if !check_only {
             rate_limit.allowance -= 1.0;