From d5b073cf3d68a48b90ac557ed3994053bc8f4ba8 Mon Sep 17 00:00:00 2001 From: grillazz Date: Mon, 5 Apr 2021 19:25:54 +0200 Subject: [PATCH] add proper repr for exceptions --- the_app/models/base.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/the_app/models/base.py b/the_app/models/base.py index ec2a316..64f4f9e 100644 --- a/the_app/models/base.py +++ b/the_app/models/base.py @@ -21,9 +21,7 @@ class Base: db_session.add(self) return await db_session.commit() except SQLAlchemyError as ex: - ic("Have to rollback, save failed:") - ic(ex) - raise HTTPException(status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, detail=ex.__str__()) + raise HTTPException(status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, detail=repr(ex)) async def delete(self, db_session: AsyncSession): try: @@ -31,6 +29,4 @@ class Base: await db_session.commit() return True except SQLAlchemyError as ex: - ic("Have to rollback, save failed:") - ic(ex) - raise HTTPException(status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, detail=ex.__str__()) + raise HTTPException(status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, detail=repr(ex))