Coverage for pepdbagent/exceptions.py: 82%

78 statements  

« prev     ^ index     » next       coverage.py v7.16.2, created at 2026-10-01 22:07 +0000

1"""Custom error types""" 

2 

3 

4class PEPDatabaseAgentError(Exception): 

5 """Base error type for pepdbagent custom errors.""" 

6 

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

8 super(PEPDatabaseAgentError, self).__init__(msg) 

9 

10 

11class SchemaError(PEPDatabaseAgentError): 

12 def __init__(self) -> None: 

13 super().__init__( 

14 """PEP_db connection error! The schema of connected db is incorrect""" 

15 ) 

16 

17 

18class RegistryPathError(PEPDatabaseAgentError): 

19 def __init__(self, msg: str = "") -> None: 

20 super().__init__(f"""Provided registry path is incorrect. {msg}""") 

21 

22 

23class ProjectNotFoundError(PEPDatabaseAgentError): 

24 def __init__(self, msg: str = "") -> None: 

25 super().__init__(f"""Project does not exist. {msg}""") 

26 

27 

28class ProjectUniqueNameError(PEPDatabaseAgentError): 

29 def __init__(self, msg: str = "") -> None: 

30 super().__init__(f"""{msg}""") 

31 

32 

33class IncorrectDateFormat(PEPDatabaseAgentError): 

34 def __init__(self, msg: str = "") -> None: 

35 super().__init__(f"""Incorrect date format was provided. {msg}""") 

36 

37 

38class FilterError(PEPDatabaseAgentError): 

39 def __init__(self, msg: str = "") -> None: 

40 super().__init__(f"""pepdbagent filter error. {msg}""") 

41 

42 

43class ProjectNotInFavorites(PEPDatabaseAgentError): 

44 """ 

45 Project doesn't exist in favorites 

46 """ 

47 

48 def __init__(self, msg: str = "") -> None: 

49 super().__init__(f"""Project is not in favorites list. {msg}""") 

50 

51 

52class ProjectAlreadyInFavorites(PEPDatabaseAgentError): 

53 """ 

54 Project doesn't exist in favorites 

55 """ 

56 

57 def __init__(self, msg: str = "") -> None: 

58 super().__init__(f"""Project is already in favorites list. {msg}""") 

59 

60 

61class SampleNotFoundError(PEPDatabaseAgentError): 

62 def __init__(self, msg: str = "") -> None: 

63 super().__init__(f"""Sample does not exist. {msg}""") 

64 

65 

66class SampleTableUpdateError(PEPDatabaseAgentError): 

67 def __init__(self, msg: str = "") -> None: 

68 super().__init__(f"""Sample table update error. {msg}""") 

69 

70 

71class ProjectDuplicatedSampleGUIDsError(SampleTableUpdateError): 

72 def __init__(self, msg: str = "") -> None: 

73 super().__init__(f"""Project has duplicated sample GUIDs. {msg}""") 

74 

75 

76class SampleAlreadyExistsError(PEPDatabaseAgentError): 

77 def __init__(self, msg: str = "") -> None: 

78 super().__init__(f"""Sample already exists. {msg}""") 

79 

80 

81class ViewNotFoundError(PEPDatabaseAgentError): 

82 def __init__(self, msg: str = "") -> None: 

83 super().__init__(f"""View does not exist. {msg}""") 

84 

85 

86class SampleNotInViewError(PEPDatabaseAgentError): 

87 def __init__(self, msg: str = "") -> None: 

88 super().__init__(f"""Sample is not in the view. {msg}""") 

89 

90 

91class SampleAlreadyInView(PEPDatabaseAgentError): 

92 """ 

93 Sample is already in the view exception 

94 """ 

95 

96 def __init__(self, msg: str = "") -> None: 

97 super().__init__(f"""Sample is already in the view. {msg}""") 

98 

99 

100class ViewAlreadyExistsError(PEPDatabaseAgentError): 

101 """ 

102 View is already in the project exception 

103 """ 

104 

105 def __init__(self, msg: str = "") -> None: 

106 super().__init__(f"""View already in the project. {msg}""") 

107 

108 

109class NamespaceNotFoundError(PEPDatabaseAgentError): 

110 def __init__(self, msg: str = "") -> None: 

111 super().__init__(f"""Project does not exist. {msg}""") 

112 

113 

114class HistoryNotFoundError(PEPDatabaseAgentError): 

115 def __init__(self, msg: str = "") -> None: 

116 super().__init__(f"""History does not exist. {msg}""") 

117 

118 

119class UserNotFoundError(PEPDatabaseAgentError): 

120 def __init__(self, msg: str = "") -> None: 

121 super().__init__(f"""User does not exist. {msg}""") 

122 

123 

124class SchemaDoesNotExistError(PEPDatabaseAgentError): 

125 def __init__(self, msg: str = "") -> None: 

126 super().__init__(f"""Schema does not exist. {msg}""") 

127 

128 

129class SchemaAlreadyExistsError(PEPDatabaseAgentError): 

130 def __init__(self, msg: str = "") -> None: 

131 super().__init__(f"""Schema already exists. {msg}""") 

132 

133 

134class SchemaVersionDoesNotExistError(PEPDatabaseAgentError): 

135 def __init__(self, msg: str = "") -> None: 

136 super().__init__(f"""Schema version does not exist. {msg}""") 

137 

138 

139class SchemaVersionAlreadyExistsError(PEPDatabaseAgentError): 

140 def __init__(self, msg: str = "") -> None: 

141 super().__init__(f"""Schema version already exists. {msg}""") 

142 

143 

144class SchemaTagDoesNotExistError(PEPDatabaseAgentError): 

145 def __init__(self, msg: str = "") -> None: 

146 super().__init__(f"""Schema tag does not exist. {msg}""") 

147 

148 

149class SchemaTagAlreadyExistsError(PEPDatabaseAgentError): 

150 def __init__(self, msg: str = "") -> None: 

151 super().__init__(f"""Schema tag already exists. {msg}""")