29
29
UndefinedColumnError ,
30
30
UndefinedTableError ,
31
31
UniqueViolationError ,
32
+ ForeignKeyViolationError ,
33
+ NotNullViolationError ,
34
+ QueryCanceledError
32
35
)
33
36
from asyncpg .pgproto import pgproto
34
37
from ..exceptions import (
@@ -414,10 +417,25 @@ async def execute(self, sentence, *args):
414
417
"""
415
418
try :
416
419
return await self ._pool .execute (sentence , * args )
420
+ except (
421
+ QueryCanceledError ,
422
+ StatementError ,
423
+ UniqueViolationError ,
424
+ ForeignKeyViolationError ,
425
+ NotNullViolationError
426
+ ) as err :
427
+ self ._logger .warning (
428
+ f"AsyncPg: { err } "
429
+ )
430
+ raise
417
431
except InterfaceError as err :
418
- raise ProviderError (f"Execute Interface Error: { err } " ) from err
432
+ raise ProviderError (
433
+ f"Execute Interface Error: { err } "
434
+ ) from err
419
435
except Exception as err :
420
- raise ProviderError (f"Execute Error: { err } " ) from err
436
+ raise ProviderError (
437
+ f"Execute Error: { err } "
438
+ ) from err
421
439
422
440
423
441
class pgCursor (SQLCursor ):
@@ -769,8 +787,24 @@ async def execute(self, sentence: Any, *args, **kwargs) -> Optional[Any]:
769
787
await self .valid_operation (sentence )
770
788
try :
771
789
self ._result = await self ._connection .execute (sentence , * args , ** kwargs )
772
- except (InvalidSQLStatementNameError , PostgresSyntaxError , UndefinedColumnError , UndefinedTableError ) as err :
773
- error = f"Sentence Error: { err } "
790
+ except (
791
+ QueryCanceledError ,
792
+ StatementError ,
793
+ UniqueViolationError ,
794
+ ForeignKeyViolationError ,
795
+ NotNullViolationError
796
+ ) as err :
797
+ self ._logger .warning (
798
+ f"AsyncPg: { err } "
799
+ )
800
+ raise
801
+ except (
802
+ InvalidSQLStatementNameError ,
803
+ PostgresSyntaxError ,
804
+ UndefinedColumnError ,
805
+ UndefinedTableError
806
+ ) as err :
807
+ error = err
774
808
except DuplicateTableError as err :
775
809
error = f"Duplicated table: { err } "
776
810
except PostgresError as err :
@@ -787,10 +821,26 @@ async def execute_many(self, sentence: str, *args):
787
821
await self .valid_operation (sentence )
788
822
try :
789
823
self ._result = await self ._connection .executemany (sentence , * args )
824
+ except (
825
+ QueryCanceledError ,
826
+ StatementError ,
827
+ UniqueViolationError ,
828
+ ForeignKeyViolationError ,
829
+ NotNullViolationError
830
+ ) as err :
831
+ self ._logger .warning (
832
+ f"AsyncPg: { err } "
833
+ )
834
+ raise
790
835
except InterfaceWarning as err :
791
836
error = f"Interface Warning: { err } "
792
- except (InvalidSQLStatementNameError , PostgresSyntaxError , UndefinedColumnError , UndefinedTableError ) as err :
793
- error = f"Sentence Error: { err } "
837
+ except (
838
+ InvalidSQLStatementNameError ,
839
+ PostgresSyntaxError ,
840
+ UndefinedColumnError ,
841
+ UndefinedTableError
842
+ ) as err :
843
+ error = err
794
844
except DuplicateTableError as err :
795
845
error = f"Duplicated table: { err } "
796
846
except PostgresError as err :
0 commit comments