Skip to content

Commit

Permalink
Merge pull request #45 from cfpb/28_standardize_messages
Browse files Browse the repository at this point in the history
Standardized error messages
  • Loading branch information
jcadam14 authored Nov 7, 2024
2 parents 753042e + e34e04b commit bc3d6f2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/regtech_cleanup_api/routers/cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ def delete_all_things(request: Request, lei: str):
if not is_valid_cleanup_lei(lei):
raise RegTechHttpException(
HTTPStatus.NOT_ACCEPTABLE,
name="Not Test LEI",
detail=f"{lei} not valid test lei.",
name="Invalid LEI",
detail=f"Not a valid LEI {lei}",
)
else:
institution_delete_helper(lei, request.state.institution_db_session)
Expand Down
20 changes: 10 additions & 10 deletions src/regtech_cleanup_api/routers/filing_cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def delete_filing(request: Request, lei: str, period_code: str):
raise RegTechHttpException(
status_code=HTTPStatus.NOT_ACCEPTABLE,
name="Invalid LEI",
detail="Not a valid LEI",
detail=f"Not a valid LEI {lei}",
)
else:
try:
Expand All @@ -58,7 +58,7 @@ def delete_helper(lei: str, period_code: str, session: Session):
raise RegTechHttpException(
status_code=HTTPStatus.INTERNAL_SERVER_ERROR,
name="Contact Info Delete Failed",
detail="Failed to delete contact info",
detail=f"Failed to delete contact info for LEI {lei}",
) from e

try:
Expand All @@ -67,7 +67,7 @@ def delete_helper(lei: str, period_code: str, session: Session):
raise RegTechHttpException(
status_code=HTTPStatus.INTERNAL_SERVER_ERROR,
name="Missing User Action Data",
detail="Failed to get user action data",
detail=f"Failed to get user action data for LEI {lei}",
) from e

try:
Expand All @@ -76,7 +76,7 @@ def delete_helper(lei: str, period_code: str, session: Session):
raise RegTechHttpException(
status_code=HTTPStatus.INTERNAL_SERVER_ERROR,
name="Submission Delete Failed",
detail="Failed to delete submission data",
detail=f"Failed to delete submission data for LEI {lei}",
) from e

try:
Expand All @@ -85,7 +85,7 @@ def delete_helper(lei: str, period_code: str, session: Session):
raise RegTechHttpException(
status_code=HTTPStatus.INTERNAL_SERVER_ERROR,
name="Filing Delete Failed",
detail="Failed to delete filing data",
detail=f"Failed to delete filing data for LEI {lei}",
) from e

try:
Expand All @@ -94,7 +94,7 @@ def delete_helper(lei: str, period_code: str, session: Session):
raise RegTechHttpException(
status_code=HTTPStatus.INTERNAL_SERVER_ERROR,
name="User Action Delete Failed",
detail="Failed to delete user action data",
detail=f"Failed to delete user action data for LEI {lei}",
) from e

delete_from_storage(period_code, lei)
Expand All @@ -113,23 +113,23 @@ def delete_submissions(request: Request, lei: str, period_code: str):
raise RegTechHttpException(
status_code=HTTPStatus.INTERNAL_SERVER_ERROR,
name="Missing User Action Data",
detail="Failed to get user action data",
detail=f"Failed to get user action data for LEI {lei}",
) from e
try:
repo.delete_submissions(session, lei, period_code)
except Exception as e:
raise RegTechHttpException(
status_code=HTTPStatus.INTERNAL_SERVER_ERROR,
name="Submission Delete Failed",
detail="Failed to delete submission data",
detail=f"Failed to delete submission data for LEI {lei}",
) from e
try:
repo.delete_user_actions(session, user_action_ids)
except Exception as e:
raise RegTechHttpException(
status_code=HTTPStatus.INTERNAL_SERVER_ERROR,
name="User Action Delete Failed",
detail="Failed to delete user action data",
detail=f"Failed to delete user action data for LEI {lei}",
) from e

delete_from_storage(period_code, lei)
Expand All @@ -140,6 +140,6 @@ def delete_submissions(request: Request, lei: str, period_code: str):
raise RegTechHttpException(
status_code=HTTPStatus.NOT_ACCEPTABLE,
name="Invalid LEI",
detail="Not a valid LEI",
detail=f"Not a valid LEI {lei}",
)
return Response(status_code=status.HTTP_204_NO_CONTENT)
12 changes: 6 additions & 6 deletions src/regtech_cleanup_api/routers/institution_cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ def delete_institution(request: Request, lei: str):
if not is_valid_cleanup_lei(lei):
raise RegTechHttpException(
HTTPStatus.NOT_ACCEPTABLE,
name="Not Test LEI",
detail=f"{lei} not valid test lei.",
name="Invalid LEI",
detail=f"Not a valid LEI {lei}",
)
else:
return delete_helper(lei, request.state.db_session)
Expand Down Expand Up @@ -70,17 +70,17 @@ def delete_helper(lei: str, session: Session):
if not res:
raise RegTechHttpException(
HTTPStatus.NOT_FOUND,
name="Institution to be deleted Not Found",
detail=f"{lei} not found.",
name="Institution Delete Failed",
detail=f"Institution LEI {lei} not found.",
)
else:
try:
oauth2_admin.delete_group(lei)
except Exception:
raise RegTechHttpException(
HTTPStatus.NOT_FOUND,
name="Group Not Found",
detail=f"The group to be deleted {lei} not found.",
name="Group Delete Failed",
detail=f"The group associated with LEI {lei} not found.",
)

return Response(status_code=status.HTTP_204_NO_CONTENT)

0 comments on commit bc3d6f2

Please sign in to comment.