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

21 statements  

« prev     ^ index     » next       coverage.py v6.5.0, created at 2023-01-10 02:32 -0800

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 "RegistryError", 

41 "UnsupportedIdGeneratorError", 

42 "UserExpressionError", 

43 "UserExpressionSyntaxError", 

44) 

45 

46 

47class RegistryError(Exception): 

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

49 

50 Notes 

51 ----- 

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

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

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

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

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

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

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

59 explicitly documented to raise exceptions outside this class hierarchy. 

60 """ 

61 

62 

63class ArgumentError(RegistryError): 

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

65 

66 

67class DatasetTypeError(RegistryError): 

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

69 

70 

71class MissingDatasetTypeError(DatasetTypeError, KeyError): 

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

73 

74 

75class DatasetTypeExpressionError(RegistryError): 

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

77 

78 

79class DataIdError(RegistryError): 

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

81 specific error types. 

82 """ 

83 

84 

85class DimensionNameError(DataIdError): 

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

87 or required dimension is not provided. 

88 """ 

89 

90 

91class DataIdValueError(DataIdError): 

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

93 

94 

95class InconsistentDataIdError(DataIdError): 

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

97 according to dimension relationships. 

98 """ 

99 

100 

101class CollectionError(RegistryError): 

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

103 

104 

105class CollectionTypeError(CollectionError): 

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

107 

108 

109class CollectionExpressionError(CollectionError): 

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

111 

112 

113class MissingCollectionError(CollectionError): 

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

115 does not exist. 

116 """ 

117 

118 

119class NoDefaultCollectionError(CollectionError): 

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

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

122 """ 

123 

124 

125class UserExpressionError(RegistryError): 

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

127 

128 

129class UserExpressionSyntaxError(UserExpressionError): 

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

131 

132 

133class ConflictingDefinitionError(RegistryError): 

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

135 conflicting record already exists. 

136 """ 

137 

138 

139class OrphanedRecordError(RegistryError): 

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

141 that is still being used in some other table. 

142 """ 

143 

144 

145class UnsupportedIdGeneratorError(ValueError): 

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

147 used for insert/import. 

148 """ 

149 

150 

151class MissingSpatialOverlapError(RegistryError): 

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

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

154 """