🐛 fix(store.py): handle HTTPStatusError exceptions and raise appropriate HTTPExceptions with corresponding status codes and details
This commit is contained in:
parent
7bd79d8302
commit
cc557f7898
1 changed files with 6 additions and 0 deletions
|
|
@ -4,6 +4,7 @@ from uuid import UUID
|
||||||
|
|
||||||
from fastapi import APIRouter, Depends, HTTPException, Query
|
from fastapi import APIRouter, Depends, HTTPException, Query
|
||||||
from httpx import HTTPStatusError
|
from httpx import HTTPStatusError
|
||||||
|
|
||||||
from langflow.services.auth import utils as auth_utils
|
from langflow.services.auth import utils as auth_utils
|
||||||
from langflow.services.database.models.user.user import User
|
from langflow.services.database.models.user.user import User
|
||||||
from langflow.services.deps import get_settings_service, get_store_service
|
from langflow.services.deps import get_settings_service, get_store_service
|
||||||
|
|
@ -193,4 +194,9 @@ async def like_component(
|
||||||
|
|
||||||
return UsersLikesResponse(likes_count=likes_count, liked_by_user=result)
|
return UsersLikesResponse(likes_count=likes_count, liked_by_user=result)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
|
if isinstance(exc, HTTPStatusError):
|
||||||
|
if exc.response.status_code == 403:
|
||||||
|
raise HTTPException(status_code=403, detail="Forbidden")
|
||||||
|
elif exc.response.status_code == 401:
|
||||||
|
raise HTTPException(status_code=401, detail="Unauthorized")
|
||||||
raise HTTPException(status_code=500, detail=str(exc))
|
raise HTTPException(status_code=500, detail=str(exc))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue