Coverage for src / sql_tool / core / exceptions.py: 100%

14 statements  

« prev     ^ index     » next       coverage.py v7.13.4, created at 2026-02-14 15:28 -0500

1"""Exception hierarchy for SQL Tool. 

2 

3All exceptions carry an exit_code for CLI return value mapping. 

4Exit codes are defined in exit_codes.py and follow CODE-PY-CLI-001 pattern. 

5""" 

6 

7from sql_tool.core.exit_codes import ExitCode 

8 

9 

10class SqlToolError(Exception): 

11 """Base exception for all SQL Tool errors.""" 

12 

13 exit_code: int = ExitCode.GENERAL_ERROR 

14 

15 def __init__(self, message: str) -> None: 

16 self.message = message 

17 super().__init__(message) 

18 

19 

20class NetworkError(SqlToolError): 

21 """Connection failures, unreachable host.""" 

22 

23 exit_code: int = ExitCode.NETWORK_ERROR 

24 

25 

26class TimeoutError(NetworkError): 

27 """Query timeout, connection timeout.""" 

28 

29 exit_code: int = ExitCode.TIMEOUT 

30 

31 

32class InputError(SqlToolError): 

33 """File not found, invalid parameters.""" 

34 

35 exit_code: int = ExitCode.INPUT_ERROR 

36 

37 

38class ConfigError(SqlToolError): 

39 """Malformed config, missing profile.""" 

40 

41 exit_code: int = ExitCode.CONFIG_ERROR