fix:chek-email
This commit is contained in:
parent
4eb0868e44
commit
33ebfa8318
|
@ -87,6 +87,7 @@ class CekEmail(BaseModel):
|
||||||
@auth_router.get("/check-email")
|
@auth_router.get("/check-email")
|
||||||
async def check_email(email: str = Query(..., description="Email yang akan dicek")):
|
async def check_email(email: str = Query(..., description="Email yang akan dicek")):
|
||||||
try:
|
try:
|
||||||
|
with conn.begin(): # transaksi otomatis
|
||||||
query = select(users).where(users.c.email == email)
|
query = select(users).where(users.c.email == email)
|
||||||
result = conn.execute(query).fetchone()
|
result = conn.execute(query).fetchone()
|
||||||
|
|
||||||
|
@ -96,9 +97,7 @@ async def check_email(email: str = Query(..., description="Email yang akan dicek
|
||||||
raise HTTPException(status_code=400, detail="false")
|
raise HTTPException(status_code=400, detail="false")
|
||||||
|
|
||||||
except SQLAlchemyError as e:
|
except SQLAlchemyError as e:
|
||||||
# Error dari SQLAlchemy (query, koneksi, dsb)
|
|
||||||
raise HTTPException(status_code=500, detail=f"Database error: {str(e)}")
|
raise HTTPException(status_code=500, detail=f"Database error: {str(e)}")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# Error lain yang tak terduga
|
|
||||||
raise HTTPException(status_code=500, detail=f"Unexpected error: {str(e)}")
|
raise HTTPException(status_code=500, detail=f"Unexpected error: {str(e)}")
|
Loading…
Reference in New Issue