feat: custom exceptions instead of direct fastapi.httpexceptions
Resolves #2
This commit is contained in:
parent
d3d3b2ca63
commit
868e56ce40
9 changed files with 73 additions and 43 deletions
|
|
@ -9,11 +9,11 @@ Exports:
|
|||
"""
|
||||
from typing import Any
|
||||
|
||||
from fastapi import HTTPException
|
||||
from src.database import get_db
|
||||
from src.exceptions import UnprocessableContent
|
||||
|
||||
from src.user.schemas import OIDCUser
|
||||
from src.user.models import User
|
||||
from src.database import get_db
|
||||
|
||||
|
||||
async def add_user_to_db(user_claims: dict[str, Any]) -> int:
|
||||
|
|
@ -21,7 +21,7 @@ async def add_user_to_db(user_claims: dict[str, Any]) -> int:
|
|||
valid_user = OIDCUser(first_name=user_claims["given_name"], last_name=user_claims["family_name"], email=user_claims["email"], oidc_id=user_claims["sub"])
|
||||
except Exception as e:
|
||||
print(e)
|
||||
raise HTTPException(status_code=422, detail="Invalid or missing OIDC data")
|
||||
raise UnprocessableContent("Invalid or missing OIDC data")
|
||||
|
||||
db = next(get_db())
|
||||
db_user = db.query(User).filter(User.oidc_id == valid_user.oidc_id).first()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue