[fractal/fractal-next] user-facing-error: Improve error messages



commit 1d85fab1ffc168b60885f0811af70240516f5d0c
Author: Kévin Commaille <zecakeh tedomum fr>
Date:   Wed Jan 26 10:23:22 2022 +0100

    user-facing-error: Improve error messages

 src/user_facing_error.rs | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/src/user_facing_error.rs b/src/user_facing_error.rs
index 92d294d66..c07bed1ca 100644
--- a/src/user_facing_error.rs
+++ b/src/user_facing_error.rs
@@ -14,9 +14,13 @@ pub trait UserFacingError {
 impl UserFacingError for HttpError {
     fn to_user_facing(self) -> String {
         match self {
-            HttpError::Reqwest(_) => {
+            HttpError::Reqwest(error) => {
                 // TODO: Add more information based on the error
-                gettext("Unable to connect to the homeserver.")
+                if error.is_timeout() {
+                    gettext("The connection timed out. Try again later.")
+                } else {
+                    gettext("Unable to connect to the homeserver.")
+                }
             }
             HttpError::ClientApi(FromHttpResponseError::Http(ServerError::Known(error))) => {
                 match error.kind {
@@ -25,11 +29,11 @@ impl UserFacingError for HttpError {
                     LimitExceeded { retry_after_ms } => {
                         if let Some(ms) = retry_after_ms {
                             gettext!(
-                                "You exceeded the homeservers rate limit, retry in {} seconds.",
+                                "You exceeded the homeserver’s rate limit, retry in {} seconds.",
                                 ms.as_secs()
                             )
                         } else {
-                            gettext("You exceeded the homeservers rate limit, try again later.")
+                            gettext("You exceeded the homeserver’s rate limit, try again later.")
                         }
                     }
                     _ => {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]