Coverage for /builds/svesch/cikit/src/cikit/errors.py: 100%

7 statements  

« prev     ^ index     » next       coverage.py v7.14.1, created at 2026-10-09 14:17 +0000

1# SPDX-License-Identifier: GPL-3.0-or-later 

2"""Common exception hierarchy for all cikit packages. 

3 

4Author: 

5 Sven Schlender 

6License: 

7 SPDX-License-Identifier: GPL-3.0-or-later 

8Date: 

9 2026-02-18 

10""" 

11 

12 

13class CiToolsError(Exception): 

14 """Base class for all cikit related errors. 

15 

16 This exception carries an optional return code that can be used 

17 by CLI entrypoints to control process exit behavior. 

18 

19 Args: 

20 message: Error message. 

21 exit_code: Exit code to use when terminating the process. 

22 """ 

23 

24 def __init__(self, message: str = "", exit_code: int = 1): 

25 super().__init__(message) 

26 self.exit_code = exit_code 

27 

28 

29class CikitSyncError(CiToolsError): 

30 """cikit data synchronization with the remote backend failed. 

31 """ 

32 

33class ResolvePathError(CiToolsError): 

34 """Error due to resolving a path. 

35 """ 

36 

37class CiRecoverableError(CiToolsError): 

38 """Exception raised for non-fatal cikit errors. 

39 

40 This exception indicates that a step has failed, but the overall 

41 execution may continue. Callers can catch this exception explicitly 

42 and decide how to record the failure. 

43 

44 Args: 

45 message: Error message describing the failure. 

46 exit_code: Exit code associated with the failure. 

47 """