Coverage for seedboxsync/core/exception.py: 100%

11 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-07-26 17:46 +0000

1# 

2# Copyright (C) 2015-2026 Guillaume Kulakowski <guillaume@kulakowski.fr> 

3# 

4# For the full copyright and license information, please view the LICENSE 

5# file that was distributed with this source code. 

6# 

7""" 

8Custom exception classes for SeedboxSync. 

9 

10This module defines the base error hierarchy used throughout the SeedboxSync 

11application. All exceptions inherit from `SeedboxSyncError`, which handles 

12logging and process termination in case of fatal errors. 

13""" 

14 

15import logging 

16import sys 

17 

18logger = logging.getLogger(__name__) 

19 

20 

21class SeedboxSyncError(Exception): 

22 """ 

23 Base exception class for all SeedboxSync errors. 

24 

25 When raised, this exception logs the error message and terminates 

26 the program immediately. It is intended for unrecoverable errors 

27 that prevent normal operation. 

28 

29 Args: 

30 msg (str): The error message to log and display before exiting. 

31 """ 

32 

33 def __init__(self, msg: str) -> None: 

34 """SeedboxSyncError init.""" 

35 logger.exception(msg) # noqa LOG004 

36 sys.exit(msg) 

37 

38 

39class SeedboxSyncConfigurationError(SeedboxSyncError): 

40 """ 

41 Exception raised for configuration-related errors. 

42 

43 This error typically occurs when the configuration file contains 

44 invalid, missing, or inconsistent settings. 

45 """ 

46 

47 

48class SyncProtocoleError(SeedboxSyncError): 

49 """ 

50 Exception raised when an unsupported or misconfigured synchronization protocol 

51 is specified. 

52 """ 

53 

54 

55class PingServiceError(SeedboxSyncError): 

56 """ 

57 Exception raised when an unsupported or misconfigured ping service 

58 is specified. 

59 """ 

60 

61 

62class SeedboxsyncConnectionError(SeedboxSyncError): 

63 """Exception raised when the connection to the remote seedbox fails."""