Skip to content

Commit

Permalink
Merge pull request #940 from ChildMindInstitute/M2-3755
Browse files Browse the repository at this point in the history
M2-3755 Error messages hotfix
  • Loading branch information
ivangolubykh authored Dec 20, 2023
2 parents 626a7a3 + 28c91b2 commit 5b3b7b8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
4 changes: 1 addition & 3 deletions src/apps/answers/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -857,9 +857,7 @@ async def get_summary_latest_report(
id_=respondent_id
)
if not respondent_exist:
raise UserNotFound(
message=f"No such respondent with id={respondent_exist}."
)
raise UserNotFound(f"No such respondent with id={respondent_id}.")

await self._is_report_server_configured(applet_id)

Expand Down
11 changes: 10 additions & 1 deletion src/apps/answers/tests/test_answers_arbitrary.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,20 @@ async def test_get_latest_summary(self, mock: CoroutineMock):
self.latest_report_url.format(
applet_id="92917a56-d586-4613-b7aa-991f2c4b15b8",
activity_id="09e3dbf0-aefb-4d0e-9177-bdb321bf3618",
respondent_id="7484f34a-3acc-4ee6-8a94-fd7299502fa1",
respondent_id="7484f34a-3acc-4ee6-8a94-fd7299502fa8",
),
)
assert response.status_code == 200

response = await self.client.post(
self.latest_report_url.format(
applet_id="92917a56-d586-4613-b7aa-991f2c4b15b8",
activity_id="09e3dbf0-aefb-4d0e-9177-bdb321bf3618",
respondent_id="7484f34a-3acc-4ee6-8a94-fd7299502fa1",
),
)
assert response.status_code == 404

@rollback
async def test_public_answer_activity_items_create_for_respondent(self):
create_data = dict(
Expand Down
6 changes: 5 additions & 1 deletion src/apps/shared/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@ class ExceptionTypes(str, Enum):


class BaseError(Exception):
message_is_template: bool = False
message = _("Oops, something went wrong.")
fallback_language = Language.ENGLISH

status_code = status.HTTP_500_INTERNAL_SERVER_ERROR
type = ExceptionTypes.UNDEFINED

def __init__(self, **kwargs):
def __init__(self, *args, **kwargs):
self.kwargs = kwargs
if args and not self.message_is_template:
self.message = args[0]

super().__init__(self.message.format(**kwargs))

@property
Expand Down

0 comments on commit 5b3b7b8

Please sign in to comment.