@@ -205,8 +205,8 @@ def get_user_profile(user_id: str):
205205 else :
206206 return Response (response = json .dumps (user_profile .to_item ()), status = 200 )
207207 except Exception as e :
208- logger . exception ( f"get- user- profile: error: { e } " )
209- return Response (response = "An internal server error occurred." , status = 500 )
208+ logging . error ( "An error occurred while fetching user profile: %s" , e , exc_info = True )
209+ return Response (response = "An internal error has occurred." , status = 500 )
210210
211211@app .route ('/user-profiles' , methods = ['GET' ])
212212def get_all_user_profiles ():
@@ -215,8 +215,8 @@ def get_all_user_profiles():
215215 json_user_profiles = [user_profile .to_item () for user_profile in user_profiles ]
216216 return Response (response = json .dumps (json_user_profiles ), status = 200 )
217217 except Exception as e :
218- logger . exception ( f"get- all- user- profiles: error: { e } " )
219- return Response (response = "An internal server error occurred." , status = 500 )
218+ logging . error ( "An error occurred while fetching all user profiles: %s" , e , exc_info = True )
219+ return Response (response = "An internal error has occurred." , status = 500 )
220220
221221@app .route ('/user-groups/<group_id>' , methods = ['POST' ])
222222def create_user_group (group_id : str ):
@@ -240,7 +240,8 @@ def create_user_group(group_id: str):
240240 except CosmosConflictError as e :
241241 return Response (response = str (e ), status = 409 )
242242 except Exception as e :
243- return Response (response = str (e ), status = 500 )
243+ logging .error ("An error occurred while creating user group: %s" , e , exc_info = True )
244+ return Response (response = "An internal error has occurred." , status = 500 )
244245
245246@app .route ('/user-groups/<group_id>' , methods = ['GET' ])
246247def get_user_group (group_id : str ):
@@ -283,7 +284,8 @@ def update_user_group(group_id: str):
283284 user_group = entities_manager .add_users_to_user_group (group_id , new_users )
284285 return Response (response = json .dumps (user_group .to_item ()), status = 200 )
285286 except (TypeError , NullValueError , MissingPropertyError , ValueError ) as e :
286- return Response (response = str (e ), status = 400 )
287+ logging .error ("An error occurred while updating user group: %s" , e , exc_info = True )
288+ return Response (response = "An internal error has occurred." , status = 400 )
287289 except SessionNotFoundError as e :
288290 logging .error ("Session not found: %s" , e , exc_info = True )
289291 return Response (response = "Session not found." , status = 404 )
0 commit comments