Skip to content

Commit 08fe8f7

Browse files
committed
refactor: simplify set_profile_picture function by removing error handling
- Removed try-except block from `set_profile_picture`, streamlining the function to directly set the profile picture. - Updated the return type to only support `ProfilePictureMessageResponse`, enhancing clarity in the response structure.
1 parent e51bae9 commit 08fe8f7

1 file changed

Lines changed: 3 additions & 11 deletions

File tree

routes/dashboard_routes.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from __future__ import annotations
1616

1717
from fastapi import APIRouter, Request
18-
from fastapi.responses import JSONResponse, RedirectResponse, Response
18+
from fastapi.responses import RedirectResponse, Response
1919
from pydantic import BaseModel, Field
2020

2121
from dependencies import (
@@ -26,7 +26,6 @@
2626
OptionalUser,
2727
ProfilePictureSvc,
2828
)
29-
from errors import NotFoundError
3029
from infrastructure.logging import get_logger
3130
from infrastructure.templates import templates
3231
from middleware.rate_limiter import Limits, limiter
@@ -206,13 +205,6 @@ async def set_profile_picture(
206205
body: SetProfilePictureRequest,
207206
user: AuthUser,
208207
svc: ProfilePictureSvc,
209-
) -> Response | ProfilePictureMessageResponse:
210-
try:
211-
await svc.set_picture(user.user_id, body.picture_id)
212-
except NotFoundError as exc:
213-
log.warning(
214-
"profile_picture_not_found", user_id=str(user.user_id), error=str(exc)
215-
)
216-
return JSONResponse({"error": "Profile picture not found"}, status_code=404)
217-
208+
) -> ProfilePictureMessageResponse:
209+
await svc.set_picture(user.user_id, body.picture_id)
218210
return ProfilePictureMessageResponse(message="Profile picture updated successfully")

0 commit comments

Comments
 (0)