Coverage for kwai/core/db/exceptions.py: 60%

10 statements  

« prev     ^ index     » next       coverage.py v7.3.0, created at 2023-09-05 17:55 +0000

1"""Module that defines all database related exceptions.""" 

2 

3 

4class DatabaseException(Exception): 

5 """Raised when a database error occurred.""" 

6 

7 def __init__(self, msg: str): 

8 super().__init__(msg) 

9 

10 

11class QueryException(DatabaseException): 

12 """Raised when the execution of a query failed.""" 

13 

14 def __init__(self, sql: str): 

15 super().__init__(sql) 

16 self._sql = sql 

17 

18 @property 

19 def sql(self) -> str: 

20 """Return the sql statement of the query.""" 

21 return self._sql