Skip to content

Commit 5f26f6f

Browse files
committed
handles exceptions
1 parent 9b9110a commit 5f26f6f

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

services/web/server/src/simcore_service_webserver/users/api.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
from models_library.users import GroupID, UserID
1919
from pydantic import EmailStr, ValidationError, parse_obj_as
2020
from simcore_postgres_database.models.users import UserRole
21+
from simcore_postgres_database.utils_groups_extra_properties import (
22+
GroupExtraPropertiesNotFoundError,
23+
)
2124

2225
from ..db.models import GroupType, groups, user_to_groups, users
2326
from ..db.plugin import get_database_engine
@@ -27,7 +30,7 @@
2730
from . import _db
2831
from ._api import get_user_credentials, get_user_invoice_address, set_user_as_deleted
2932
from ._preferences_api import get_frontend_user_preferences_aggregation
30-
from .exceptions import UserNotFoundError
33+
from .exceptions import MissingGroupExtraPropertiesForProductError, UserNotFoundError
3134
from .schemas import ProfileGet, ProfileUpdate
3235

3336
_logger = logging.getLogger(__name__)
@@ -45,6 +48,7 @@ async def get_user_profile(
4548
) -> ProfileGet:
4649
"""
4750
:raises UserNotFoundError:
51+
:raises MissingGroupExtraPropertiesForProductError: when product is not properly configured
4852
"""
4953

5054
engine = get_database_engine(app)
@@ -107,9 +111,14 @@ async def get_user_profile(
107111
if not user_profile:
108112
raise UserNotFoundError(uid=user_id)
109113

110-
preferences = await get_frontend_user_preferences_aggregation(
111-
app, user_id=user_id, product_name=product_name
112-
)
114+
try:
115+
preferences = await get_frontend_user_preferences_aggregation(
116+
app, user_id=user_id, product_name=product_name
117+
)
118+
except GroupExtraPropertiesNotFoundError as err:
119+
raise MissingGroupExtraPropertiesForProductError(
120+
user_id=user_id, product_name=product_name
121+
) from err
113122

114123
# NOTE: expirationDate null is not handled properly in front-end.
115124
# https://github.com/ITISFoundation/osparc-simcore/issues/5244

services/web/server/src/simcore_service_webserver/users/exceptions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,7 @@ class AlreadyPreRegisteredError(UsersBaseError):
5050
class BillingDetailsNotFoundError(UsersBaseError):
5151
# NOTE: this is for internal log and should not be transmitted to the final user
5252
msg_template = "Billing details are missing for user_id={user_id}. TIP: Check whether this user is pre-registered"
53+
54+
55+
class MissingGroupExtraPropertiesForProductError(UsersBaseError):
56+
msg_template = "Missing group_extra_property for product_name={product_name}"

0 commit comments

Comments
 (0)