Coverage for python/lsst/daf/butler/registry/_exceptions.py: 100%

22 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-06-07 02:10 -0700

1# This file is part of daf_butler. 

2# 

3# Developed for the LSST Data Management System. 

4# This product includes software developed by the LSST Project 

5# (http://www.lsst.org). 

6# See the COPYRIGHT file at the top-level directory of this distribution 

7# for details of code ownership. 

8# 

9# This program is free software: you can redistribute it and/or modify 

10# it under the terms of the GNU General Public License as published by 

11# the Free Software Foundation, either version 3 of the License, or 

12# (at your option) any later version. 

13# 

14# This program is distributed in the hope that it will be useful, 

15# but WITHOUT ANY WARRANTY; without even the implied warranty of 

16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

17# GNU General Public License for more details. 

18# 

19# You should have received a copy of the GNU General Public License 

20# along with this program. If not, see <http://www.gnu.org/licenses/>. 

21 

22 

23__all__ = ( 

24 "ArgumentError", 

25 "CollectionError", 

26 "CollectionExpressionError", 

27 "CollectionTypeError", 

28 "ConflictingDefinitionError", 

29 "DataIdError", 

30 "DataIdValueError", 

31 "DatasetTypeError", 

32 "DatasetTypeExpressionError", 

33 "DimensionNameError", 

34 "InconsistentDataIdError", 

35 "MissingCollectionError", 

36 "MissingDatasetTypeError", 

37 "MissingSpatialOverlapError", 

38 "NoDefaultCollectionError", 

39 "OrphanedRecordError", 

40 "RegistryConsistencyError", 

41 "RegistryError", 

42 "UnsupportedIdGeneratorError", 

43 "UserExpressionError", 

44 "UserExpressionSyntaxError", 

45) 

46 

47 

48class RegistryError(Exception): 

49 """Base class for many exception classes produced by Registry methods. 

50 

51 Notes 

52 ----- 

53 The client code that needs to handle exceptions generated by the Registry 

54 methods can catch this class or one of its many subclasses as described by 

55 the particular method documentation. While most of the Registry methods 

56 should only raise the exceptions of this type, it is hard to guarantee 

57 that they will never raise other exception types. If the client needs to 

58 handle all possible exceptions, then it should also catch a standard 

59 `Exception` type as well. Additionally, some Registry methods can be 

60 explicitly documented to raise exceptions outside this class hierarchy. 

61 """ 

62 

63 

64class ArgumentError(RegistryError): 

65 """Exception raised when method arguments are invalid or inconsistent.""" 

66 

67 

68class DatasetTypeError(RegistryError): 

69 """Exception raised for problems with dataset types.""" 

70 

71 

72class MissingDatasetTypeError(DatasetTypeError, KeyError): 

73 """Exception raised when a dataset type does not exist.""" 

74 

75 

76class DatasetTypeExpressionError(RegistryError): 

77 """Exception raised for an incorrect dataset type expression.""" 

78 

79 

80class DataIdError(RegistryError): 

81 """Exception raised for incorrect data IDs, this is a base class for other 

82 specific error types. 

83 """ 

84 

85 

86class DimensionNameError(DataIdError): 

87 """Exception raised when a dimension specified in a data ID does not exist 

88 or required dimension is not provided. 

89 """ 

90 

91 

92class DataIdValueError(DataIdError): 

93 """Exception raised when a value specified in a data ID does not exist.""" 

94 

95 

96class InconsistentDataIdError(DataIdError): 

97 """Exception raised when a data ID contains contradictory key-value pairs, 

98 according to dimension relationships. 

99 """ 

100 

101 

102class CollectionError(RegistryError): 

103 """Exception raised for collection-related errors.""" 

104 

105 

106class CollectionTypeError(CollectionError): 

107 """Exception raised when type of a collection is incorrect.""" 

108 

109 

110class CollectionExpressionError(CollectionError): 

111 """Exception raised for an incorrect collection expression.""" 

112 

113 

114class MissingCollectionError(CollectionError): 

115 """Exception raised when an operation attempts to use a collection that 

116 does not exist. 

117 """ 

118 

119 

120class NoDefaultCollectionError(CollectionError): 

121 """Exception raised when a collection is needed, but collection argument 

122 is not provided and default collection is not defined in registry. 

123 """ 

124 

125 

126class UserExpressionError(RegistryError): 

127 """Exception raised for problems with user expression.""" 

128 

129 

130class UserExpressionSyntaxError(UserExpressionError): 

131 """Exception raised when a user query expression cannot be parsed.""" 

132 

133 

134class ConflictingDefinitionError(RegistryError): 

135 """Exception raised when trying to insert a database record when a 

136 conflicting record already exists. 

137 """ 

138 

139 

140class OrphanedRecordError(RegistryError): 

141 """Exception raised when trying to remove or modify a database record 

142 that is still being used in some other table. 

143 """ 

144 

145 

146class UnsupportedIdGeneratorError(ValueError): 

147 """Exception raised when an unsupported `DatasetIdGenEnum` option is 

148 used for insert/import. 

149 """ 

150 

151 

152class MissingSpatialOverlapError(RegistryError): 

153 """Exception raised when a spatial overlap relationship needed by a query 

154 has not been precomputed and cannot be computed on-the-fly. 

155 """ 

156 

157 

158class RegistryConsistencyError(RegistryError): 

159 """Exception raised when an internal registry consistency check fails, 

160 usually means bug in the Regitry itself. 

161 """