mirror of
https://github.com/grillazz/fastapi-sqlalchemy-asyncpg.git
synced 2025-08-26 16:40:40 +03:00
add proper repr for exceptions
This commit is contained in:
parent
4227e716a5
commit
d5b073cf3d
@ -21,9 +21,7 @@ class Base:
|
|||||||
db_session.add(self)
|
db_session.add(self)
|
||||||
return await db_session.commit()
|
return await db_session.commit()
|
||||||
except SQLAlchemyError as ex:
|
except SQLAlchemyError as ex:
|
||||||
ic("Have to rollback, save failed:")
|
raise HTTPException(status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, detail=repr(ex))
|
||||||
ic(ex)
|
|
||||||
raise HTTPException(status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, detail=ex.__str__())
|
|
||||||
|
|
||||||
async def delete(self, db_session: AsyncSession):
|
async def delete(self, db_session: AsyncSession):
|
||||||
try:
|
try:
|
||||||
@ -31,6 +29,4 @@ class Base:
|
|||||||
await db_session.commit()
|
await db_session.commit()
|
||||||
return True
|
return True
|
||||||
except SQLAlchemyError as ex:
|
except SQLAlchemyError as ex:
|
||||||
ic("Have to rollback, save failed:")
|
raise HTTPException(status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, detail=repr(ex))
|
||||||
ic(ex)
|
|
||||||
raise HTTPException(status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, detail=ex.__str__())
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user