Skip to content

Commit 7eacceb

Browse files
committed
improve messages
1 parent 14afd7f commit 7eacceb

File tree

6 files changed

+90
-46
lines changed

6 files changed

+90
-46
lines changed

packages/service-library/src/servicelib/aiohttp/rest_middlewares.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
DEFAULT_API_VERSION = "v0"
3737
_FMSG_INTERNAL_ERROR_USER_FRIENDLY = user_message(
3838
"We apologize for the inconvenience. "
39-
"The issue has been recorded, please report it if it persists."
39+
"The issue has been recorded, please report it if it persists.",
40+
_version=1,
4041
)
4142

4243

services/web/server/src/simcore_service_webserver/constants.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# pylint:disable=unused-import
22

3+
from sys import version
34
from typing import Final
45

56
from common_library.user_messages import user_message
@@ -48,7 +49,7 @@
4849

4950

5051
MSG_TRY_AGAIN_OR_SUPPORT: Final[str] = user_message(
51-
"Please try again shortly. If the issue persists, contact support."
52+
"Please try again shortly. If the issue persists, contact support.", _version=1
5253
)
5354

5455
__all__: tuple[str, ...] = (

services/web/server/src/simcore_service_webserver/director_v2/_controller/_rest_exceptions.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,17 @@ async def _handler_director_service_error_as_503_or_4xx(
8787
_TO_HTTP_ERROR_MAP: ExceptionToHttpErrorMap = {
8888
UserDefaultWalletNotFoundError: HttpErrorInfo(
8989
status.HTTP_404_NOT_FOUND,
90-
user_message("Default wallet not found but necessary for computations"),
90+
user_message(
91+
"A default wallet is required for running computations but could not be found.",
92+
_version=1,
93+
),
9194
),
9295
WalletNotEnoughCreditsError: HttpErrorInfo(
9396
status.HTTP_402_PAYMENT_REQUIRED,
94-
user_message("Wallet does not have enough credits for computations. {reason}"),
97+
user_message(
98+
"Your wallet does not have sufficient credits to run this computation. {reason}",
99+
_version=1,
100+
),
95101
),
96102
}
97103

services/web/server/src/simcore_service_webserver/groups/_common/exceptions_handlers.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,32 +24,40 @@
2424
_TO_HTTP_ERROR_MAP: ExceptionToHttpErrorMap = {
2525
UserNotFoundError: HttpErrorInfo(
2626
status.HTTP_404_NOT_FOUND,
27-
user_message("User {uid} or {email} not found"),
27+
user_message(
28+
"The user with ID {uid} or email {email} could not be found.", _version=1
29+
),
2830
),
2931
GroupNotFoundError: HttpErrorInfo(
3032
status.HTTP_404_NOT_FOUND,
31-
user_message("Group {gid} not found"),
33+
user_message("The group with ID {gid} could not be found.", _version=1),
3234
),
3335
UserInGroupNotFoundError: HttpErrorInfo(
3436
status.HTTP_404_NOT_FOUND,
35-
user_message("User not found in group {gid}"),
37+
user_message("The user is not a member of group {gid}.", _version=1),
3638
),
3739
UserAlreadyInGroupError: HttpErrorInfo(
3840
status.HTTP_409_CONFLICT,
39-
user_message("User is already in group {gid}"),
41+
user_message("The user is already a member of group {gid}.", _version=1),
4042
),
4143
UserInsufficientRightsError: HttpErrorInfo(
4244
status.HTTP_403_FORBIDDEN,
43-
user_message("Insufficient rights for {permission} access to group {gid}"),
45+
user_message(
46+
"You do not have sufficient rights for {permission} access to group {gid}.",
47+
_version=1,
48+
),
4449
),
4550
# scicrunch
4651
InvalidRRIDError: HttpErrorInfo(
4752
status.HTTP_409_CONFLICT,
48-
user_message("Invalid RRID {rrid}"),
53+
user_message("The RRID {rrid} is not valid.", _version=1),
4954
),
5055
ScicrunchError: HttpErrorInfo(
5156
status.HTTP_409_CONFLICT,
52-
user_message("Cannot get RRID since scicrunch.org service is not reachable."),
57+
user_message(
58+
"Unable to retrieve RRID information because the scicrunch.org service is currently unavailable.",
59+
_version=1,
60+
),
5361
),
5462
}
5563

services/web/server/src/simcore_service_webserver/login/_constants.py

Lines changed: 57 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,89 +3,114 @@
33
from common_library.user_messages import user_message
44

55
MSG_2FA_CODE_SENT: Final[str] = user_message(
6-
"A code was sent by SMS to {phone_number}."
6+
"A verification code has been sent via SMS to {phone_number}.", _version=1
77
)
88
MSG_2FA_UNAVAILABLE: Final[str] = user_message(
9-
"Two-factor authentication is temporarily unavailable"
9+
"Two-factor authentication is temporarily unavailable. Please try again later.",
10+
_version=1,
11+
)
12+
MSG_ACTIVATED: Final[str] = user_message(
13+
"Your account has been successfully activated.", _version=1
1014
)
11-
MSG_ACTIVATED: Final[str] = user_message("Your account has been activated.")
1215
MSG_ACTIVATION_REQUIRED: Final[str] = user_message(
13-
"Please activate your account via the email we sent before logging in."
16+
"Please activate your account using the activation link we sent to your email before logging in.",
17+
_version=1,
1418
)
1519
MSG_AUTH_FAILED: Final[str] = user_message(
16-
"Authorization was not successful. Please check your credentials and try again."
20+
"We couldn't sign you in with those credentials. Please check your email and password and try again.",
21+
_version=1,
1722
)
1823
MSG_CANT_SEND_MAIL: Final[str] = user_message(
19-
"Unable to send email at this time. Please try again later."
24+
"We're unable to send emails at this time. Please try again later.", _version=1
2025
)
2126
MSG_CHANGE_EMAIL_REQUESTED: Final[str] = user_message(
22-
"Please click the verification link sent to your new email address."
27+
"Please check your new email address and click the verification link we sent you.",
28+
_version=1,
29+
)
30+
MSG_EMAIL_CHANGED: Final[str] = user_message(
31+
"Your email address has been successfully updated.", _version=1
2332
)
24-
MSG_EMAIL_CHANGED: Final[str] = user_message("Your email address has been updated.")
2533
MSG_EMAIL_ALREADY_REGISTERED: Final[str] = user_message(
26-
"This email address is already registered. Try logging in or use a different address."
34+
"This email address is already associated with an account. Please sign in or use a different email address.",
35+
_version=1,
2736
)
2837
MSG_EMAIL_SENT: Final[str] = user_message(
29-
"An email was sent to {email} with further instructions."
38+
"We've sent an email to {email} with further instructions.", _version=1
39+
)
40+
MSG_LOGGED_IN: Final[str] = user_message("You have successfully signed in.", _version=1)
41+
MSG_LOGGED_OUT: Final[str] = user_message(
42+
"You have successfully signed out.", _version=1
3043
)
31-
MSG_LOGGED_IN: Final[str] = user_message("You have successfully logged in.")
32-
MSG_LOGGED_OUT: Final[str] = user_message("You have successfully logged out.")
3344
MSG_OFTEN_RESET_PASSWORD: Final[str] = user_message(
34-
"You've requested a password reset recently. Please use the link we sent you or wait before requesting again."
45+
"You've recently requested a password reset. Please check your email for the reset link or wait before requesting another one.",
46+
_version=1,
3547
)
3648
MSG_PASSWORD_CHANGE_NOT_ALLOWED: Final[str] = user_message(
3749
"Unable to reset password. Permissions may have expired or been removed. "
38-
"Please try again, or contact support if the problem continues: {support_email}"
50+
"Please try again, or contact support if the problem continues: {support_email}",
51+
_version=1,
52+
)
53+
MSG_PASSWORD_CHANGED: Final[str] = user_message(
54+
"Your password has been updated.", _version=1
3955
)
40-
MSG_PASSWORD_CHANGED: Final[str] = user_message("Your password has been updated.")
4156
MSG_PASSWORD_MISMATCH: Final[str] = user_message(
42-
"Password and confirmation do not match. Please try again."
57+
"Password and confirmation do not match. Please try again.", _version=1
4358
)
4459
MSG_PHONE_MISSING: Final[str] = user_message(
45-
"No phone number is associated with this account."
60+
"No phone number is associated with this account.", _version=1
4661
)
4762
MSG_UNAUTHORIZED_CODE_RESEND_2FA: Final[str] = user_message(
48-
"You can no longer resend the code. Please restart the verification process."
63+
"You can no longer resend the code. Please restart the verification process.",
64+
_version=1,
4965
)
5066
MSG_UNAUTHORIZED_LOGIN_2FA: Final[str] = user_message(
51-
"You can no longer submit a code. Please restart the login process."
67+
"You can no longer submit a code. Please restart the login process.", _version=1
5268
)
5369
MSG_UNAUTHORIZED_REGISTER_PHONE: Final[str] = user_message(
54-
"Phone registration is no longer allowed. Please restart the registration process."
70+
"Phone registration is no longer allowed. Please restart the registration process.",
71+
_version=1,
5572
)
5673
MSG_UNAUTHORIZED_PHONE_CONFIRMATION: Final[str] = user_message(
57-
"You can no longer submit a code. Please restart the confirmation process."
74+
"You can no longer submit a code. Please restart the confirmation process.",
75+
_version=1,
76+
)
77+
MSG_UNKNOWN_EMAIL: Final[str] = user_message(
78+
"This email address is not registered.", _version=1
5879
)
59-
MSG_UNKNOWN_EMAIL: Final[str] = user_message("This email address is not registered.")
6080
MSG_USER_DELETED: Final[str] = user_message(
61-
"This account is scheduled for deletion. To reactivate it or for more information, please contact support: {support_email}"
81+
"This account is scheduled for deletion. To reactivate it or for more information, please contact support: {support_email}",
82+
_version=1,
6283
)
6384
MSG_USER_BANNED: Final[str] = user_message(
64-
"Access to this account is no longer available. Please contact support for more information: {support_email}"
85+
"Access to this account is no longer available. Please contact support for more information: {support_email}",
86+
_version=1,
6587
)
6688
MSG_USER_EXPIRED: Final[str] = user_message(
67-
"This account has expired and access is no longer available. Please contact support for assistance: {support_email}"
89+
"This account has expired and access is no longer available. Please contact support for assistance: {support_email}",
90+
_version=1,
6891
)
6992
MSG_USER_DISABLED: Final[str] = user_message(
70-
"This account has been disabled and cannot be registered again. Please contact support for details: {support_email}"
93+
"This account has been disabled and cannot be registered again. Please contact support for details: {support_email}",
94+
_version=1,
7195
)
7296
MSG_WRONG_2FA_CODE__INVALID: Final[str] = user_message(
73-
"The code entered is not valid. Please enter a valid code or generate a new one."
97+
"The code entered is not valid. Please enter a valid code or generate a new one.",
98+
_version=1,
7499
)
75100
MSG_WRONG_2FA_CODE__EXPIRED: Final[str] = user_message(
76-
"The code has expired. Please generate a new code."
101+
"The code has expired. Please generate a new code.", _version=1
77102
)
78103
MSG_WRONG_CAPTCHA__INVALID: Final[str] = user_message(
79-
"The CAPTCHA entered is incorrect. Please try again."
104+
"The CAPTCHA entered is incorrect. Please try again.", _version=1
80105
)
81106
MSG_WRONG_PASSWORD: Final[str] = user_message(
82-
"The password is incorrect. Please try again."
107+
"The password is incorrect. Please try again.", _version=1
83108
)
84109
MSG_WEAK_PASSWORD: Final[str] = user_message(
85-
"Password must be at least {LOGIN_PASSWORD_MIN_LENGTH} characters long."
110+
"Password must be at least {LOGIN_PASSWORD_MIN_LENGTH} characters long.", _version=1
86111
)
87112
MSG_INVITATIONS_CONTACT_SUFFIX: Final[str] = user_message(
88-
"Please contact our support team to request a new invitation."
113+
"Please contact our support team to request a new invitation.", _version=1
89114
)
90115

91116
# Login Accepted Response Codes:

services/web/server/src/simcore_service_webserver/products/_controller/rest_exceptions.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,16 @@
1313
_TO_HTTP_ERROR_MAP: ExceptionToHttpErrorMap = {
1414
ProductNotFoundError: HttpErrorInfo(
1515
status.HTTP_404_NOT_FOUND,
16-
user_message("{product_name} was not found"),
16+
user_message(
17+
"This product could not be found." + MSG_TRY_AGAIN_OR_SUPPORT, _version=1
18+
),
1719
),
1820
MissingStripeConfigError: HttpErrorInfo(
1921
status.HTTP_503_SERVICE_UNAVAILABLE,
2022
user_message(
21-
"{product_name} service is currently unavailable."
22-
+ MSG_TRY_AGAIN_OR_SUPPORT
23+
"This service is temporarily unavailable due to a configuration issue. "
24+
+ MSG_TRY_AGAIN_OR_SUPPORT,
25+
_version=1,
2326
),
2427
),
2528
}

0 commit comments

Comments
 (0)