Skip to content

Commit 3c3f8c0

Browse files
committed
error messages
1 parent 31c6fb7 commit 3c3f8c0

File tree

4 files changed

+33
-15
lines changed

4 files changed

+33
-15
lines changed

services/web/server/src/simcore_service_webserver/studies_dispatcher/_errors.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,43 @@ class StudyDispatcherError(WebServerBaseError, ValueError): ...
88

99
class IncompatibleServiceError(StudyDispatcherError):
1010
msg_template = user_message(
11-
"None of the registered services can handle '{file_type}'"
11+
"None of the registered services can handle '{file_type}' files.", _version=1
1212
)
1313

1414

1515
class FileToLargeError(StudyDispatcherError):
16-
msg_template = user_message("File size {file_size_in_mb} MB is over allowed limit")
16+
msg_template = user_message(
17+
"File size {file_size_in_mb} MB exceeds the allowed limit.", _version=1
18+
)
1719

1820

1921
class ServiceNotFoundError(StudyDispatcherError):
20-
msg_template = user_message("Service {service_key}:{service_version} not found")
22+
msg_template = user_message(
23+
"Service {service_key}:{service_version} could not be found.", _version=1
24+
)
2125

2226

2327
class InvalidRedirectionParamsError(StudyDispatcherError):
24-
msg_template = "Invalid link"
28+
msg_template = user_message(
29+
"The provided link is invalid or incomplete.", _version=1
30+
)
2531

2632

2733
class GuestUsersLimitError(StudyDispatcherError):
2834
msg_template = user_message(
29-
"Maximum number of guests was reached. Please login with a registered user or try again later"
35+
"Maximum number of guest users has been reached. Please log in with a registered account or try again later.",
36+
_version=1,
3037
)
3138

3239

3340
class GuestUserNotAllowedError(StudyDispatcherError):
34-
msg_template = "Guest users are not allowed to access this resource configuration."
41+
msg_template = user_message(
42+
"Guest users are not allowed to access this resource.", _version=1
43+
)
3544

3645

3746
class ProjectWorkbenchMismatchError(StudyDispatcherError):
38-
msg_template = "Project {project_uuid} exists but does not seem to be a viewer generated by this module"
47+
msg_template = user_message(
48+
"Project {project_uuid} appears to be corrupted and cannot be accessed properly.",
49+
_version=1,
50+
)

services/web/server/src/simcore_service_webserver/studies_dispatcher/_redirects_handlers.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,17 @@ def _create_error_redirect_with_logging(
123123

124124
def _create_simple_error_redirect(
125125
request: web.Request,
126-
err: Exception,
126+
public_error: Exception,
127127
*,
128128
status_code: int,
129129
) -> web.HTTPFound:
130-
"""Helper to create simple error redirect without logging"""
131-
user_error_msg = f"Sorry, we cannot dispatch your study: {err}"
130+
"""Helper to create simple error redirect without logging
131+
132+
WARNING: note that the `public_error` is exposed as-is in the user-message
133+
"""
134+
user_error_msg = user_message(
135+
f"Unable to open your project: {public_error}", _version=1
136+
)
132137
return _create_redirect_response_to_error_page(
133138
request.app,
134139
message=user_error_msg,
@@ -152,7 +157,7 @@ async def wrapper(request: web.Request) -> web.StreamResponse:
152157
message=user_message(
153158
"Access is restricted to registered users.<br/><br/>"
154159
"If you don't have an account, please contact support to request one.<br/><br/>",
155-
_version=1,
160+
_version=2,
156161
),
157162
status_code=status.HTTP_401_UNAUTHORIZED,
158163
) from err
@@ -184,8 +189,9 @@ async def wrapper(request: web.Request) -> web.StreamResponse:
184189
request,
185190
err,
186191
message=user_message(
187-
"The link you provided is invalid because it doesn't contain any or invalid information related to data or a service."
188-
"Please check the link and make sure it is correct."
192+
"The link you provided is invalid because it doesn't contain valid information related to data or a service. "
193+
"Please check the link and make sure it is correct.",
194+
_version=1,
189195
),
190196
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
191197
tip="The link might be corrupted",

services/web/server/tests/unit/with_dbs/04/studies_dispatcher/test_studies_dispatcher_handlers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ async def test_viewer_redirect_with_file_type_errors(client: TestClient):
580580
message, status_code = assert_error_in_fragment(resp)
581581

582582
assert status_code == status.HTTP_422_UNPROCESSABLE_ENTITY
583-
assert "type" in message.lower()
583+
assert "link" in message.lower()
584584

585585

586586
async def test_viewer_redirect_with_client_errors(client: TestClient):

services/web/server/tests/unit/with_dbs/04/studies_dispatcher/test_studies_dispatcher_studies_access.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def mocks_on_projects_api(mocker: MockerFixture) -> None:
176176
"""
177177
import simcore_service_webserver.projects._projects_service
178178

179-
mocker.patch.patch(
179+
mocker.patch.object(
180180
simcore_service_webserver.projects._projects_service,
181181
"_get_project_share_state",
182182
return_value=ProjectShareState(

0 commit comments

Comments
 (0)