Coverage for src/debputy/exceptions.py: 92%

66 statements  

« prev     ^ index     » next       coverage.py v7.8.2, created at 2026-01-26 19:30 +0000

1"""Exceptions with basic type annotations for accessors and constructors.""" 

2 

3from typing import Any, cast, TYPE_CHECKING 

4 

5if TYPE_CHECKING: 

6 from debputy.plugin.api.impl_types import DebputyPluginMetadata 

7 

8 

9class DebputyRuntimeError(RuntimeError): 

10 

11 def __init__(self, message: str, *args: Any) -> None: 

12 super().__init__(message, *args) 

13 

14 @property 

15 def message(self) -> str: 

16 return cast("str", self.args[0]) 

17 

18 

19class DebputyRuntimeErrorWithPreamble(DebputyRuntimeError): 

20 

21 def render_preamble(self) -> None: 

22 raise NotImplementedError 

23 

24 

25class DebputyBuildStepError(DebputyRuntimeError): 

26 pass 

27 

28 

29class DebputySubstitutionError(DebputyRuntimeError): 

30 pass 

31 

32 

33class DebputyManifestVariableRequiresDebianDirError(DebputySubstitutionError): 

34 pass 

35 

36 

37class DebputyDpkgGensymbolsError(DebputyRuntimeError): 

38 pass 

39 

40 

41class SymlinkLoopError(ValueError): 

42 

43 def __init__(self, message: str, *args: Any) -> None: 

44 super().__init__(message, *args) 

45 

46 @property 

47 def message(self) -> str: 

48 return cast("str", self.args[0]) 

49 

50 

51class PureVirtualPathError(TypeError): 

52 

53 def __init__(self, message: str, *args: Any) -> None: 

54 super().__init__(message, *args) 

55 

56 @property 

57 def message(self) -> str: 

58 return cast("str", self.args[0]) 

59 

60 

61class TestPathWithNonExistentFSPathError(TypeError): 

62 

63 def __init__(self, message: str, *args: Any) -> None: 

64 super().__init__(message, *args) 

65 

66 @property 

67 def message(self) -> str: 

68 return cast("str", self.args[0]) 

69 

70 

71class DebputyFSError(DebputyRuntimeError): 

72 pass 

73 

74 

75class DebputyFSIsROError(DebputyFSError): 

76 pass 

77 

78 

79class PluginBaseError(DebputyRuntimeError): 

80 pass 

81 

82 

83class DebputyPluginRuntimeError(PluginBaseError): 

84 pass 

85 

86 

87class PluginNotFoundError(PluginBaseError): 

88 pass 

89 

90 

91class PluginInitializationError(PluginBaseError): 

92 pass 

93 

94 

95class PluginIncorrectRegistrationError(PluginInitializationError): 

96 pass 

97 

98 

99class PluginMetadataError(PluginBaseError): 

100 pass 

101 

102 

103class PluginConflictError(PluginBaseError): 

104 

105 def __init__( 

106 self, 

107 message: str, 

108 plugin_a: "DebputyPluginMetadata", 

109 plugin_b: "DebputyPluginMetadata", 

110 *args: Any, 

111 ) -> None: 

112 super().__init__(message, plugin_a, plugin_b, *args) 

113 

114 @property 

115 def plugin_a(self) -> "DebputyPluginMetadata": 

116 return cast("DebputyPluginMetadata", self.args[1]) 

117 

118 @property 

119 def plugin_b(self) -> "DebputyPluginMetadata": 

120 return cast("DebputyPluginMetadata", self.args[2]) 

121 

122 

123class PluginAPIViolationError(PluginBaseError): 

124 pass 

125 

126 

127class UnhandledOrUnexpectedErrorFromPluginError(PluginBaseError): 

128 pass 

129 

130 

131class DebputyMetadataAccessError(DebputyPluginRuntimeError): 

132 pass