1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302
|
"""
Python-Redmine tries its best to provide human-readable errors in all situations.
This is a list of all exceptions or warnings that Python-Redmine can throw/raise.
"""
class BaseRedmineWarning(Warning):
"""
Base warning class for Redmine warnings.
"""
class PerformanceWarning(BaseRedmineWarning):
"""
Warning raised when there's a possible performance impact.
"""
class BaseRedmineError(Exception):
"""
Base exception class for Redmine exceptions.
"""
class ResourceError(BaseRedmineError):
"""
Unsupported Redmine resource exception.
"""
def __init__(self):
super().__init__('Unsupported Redmine resource')
class NoFileError(BaseRedmineError):
"""
File doesn't exist or is empty exception.
"""
def __init__(self):
super().__init__("Can't upload a file that doesn't exist or is empty")
class FileObjectError(BaseRedmineError):
"""
File-like object isn't supported as it doesn't support the read(size) method.
"""
def __init__(self):
super().__init__("File-like object doesn't support the read(size) method")
class ResourceNotFoundError(BaseRedmineError):
"""
Requested resource doesn't exist.
"""
def __init__(self):
super().__init__("Requested resource doesn't exist")
class ConflictError(BaseRedmineError):
"""
Resource version on the server is newer than on the client.
"""
def __init__(self):
super().__init__('Resource version on the server is newer than on the client')
class AuthError(BaseRedmineError):
"""
Invalid authentication details.
"""
def __init__(self):
super().__init__('Invalid authentication details')
class ImpersonateError(BaseRedmineError):
"""
Invalid impersonate login provided.
"""
def __init__(self):
super().__init__("Impersonate login provided doesn't exist or isn't active")
class ServerError(BaseRedmineError):
"""
Redmine internal error.
"""
def __init__(self):
super().__init__('Redmine returned internal error, check Redmine logs for details')
class RequestEntityTooLargeError(BaseRedmineError):
"""
Size of the request exceeds the capacity limit on the server.
"""
def __init__(self):
super().__init__(
"The requested resource doesn't allow POST requests or the size of the request exceeds the capacity limit")
class UnknownError(BaseRedmineError):
"""
Redmine returned unknown error.
"""
def __init__(self, status_code):
self.status_code = status_code
super().__init__(f'Redmine returned unknown error with the status code {status_code}')
class ValidationError(BaseRedmineError):
"""
Redmine validation errors occurred on create/update resource.
"""
def __init__(self, error):
super().__init__(error)
class ResourceSetIndexError(BaseRedmineError):
"""
Index doesn't exist in the ResourceSet.
"""
def __init__(self):
super().__init__('Resource not available by requested index')
class ResourceSetFilterLookupError(BaseRedmineError):
"""
Resource set filter method received an invalid lookup in one of the filters.
"""
def __init__(self, lookup, f):
super().__init__(f'Received an invalid lookup "{lookup}" in "{f}" filter')
class ResourceBadMethodError(BaseRedmineError):
"""
Resource doesn't support the requested method.
"""
def __init__(self):
super().__init__("Resource doesn't support the requested method")
class ResourceFilterError(BaseRedmineError):
"""
Resource doesn't support requested filter(s).
"""
def __init__(self):
super().__init__("Resource doesn't support requested filter(s)")
class ResourceNoFiltersProvidedError(BaseRedmineError):
"""
No filter(s) provided.
"""
def __init__(self):
super().__init__('Resource needs some filters to be filtered on')
class ResourceNoFieldsProvidedError(BaseRedmineError):
"""
No field(s) provided.
"""
def __init__(self):
super().__init__('Resource needs some fields to be set to be created/updated')
class ResourceAttrError(BaseRedmineError, AttributeError):
"""
Resource doesn't have the requested attribute.
"""
def __init__(self):
super().__init__("Resource doesn't have the requested attribute")
class ReadonlyAttrError(BaseRedmineError):
"""
Resource can't set attribute that is read only.
"""
def __init__(self):
super().__init__("Can't set read only attribute")
class VersionFormatError(BaseRedmineError):
"""
Version format provided isn't supported. SemVer is the only format accepted.
"""
def __init__(self, version):
super().__init__(
f"Version in the {version} format isn't supported, please provide numeric version in the form of X.X.X")
class VersionMismatchError(BaseRedmineError):
"""
Feature isn't supported on specified Redmine version.
"""
def __init__(self, feature):
super().__init__(f"{feature} isn't supported on specified Redmine version")
class ResourceVersionMismatchError(VersionMismatchError):
"""
Resource isn't supported on specified Redmine version.
"""
def __init__(self):
super().__init__('Resource')
class ResultSetTotalCountError(BaseRedmineError):
"""
ResultSet hasn't been yet evaluated and cannot yield a total_count.
"""
def __init__(self):
super().__init__('Total count is unknown before evaluation')
class CustomFieldValueError(BaseRedmineError):
"""
Custom fields should be passed as a list of dictionaries.
"""
def __init__(self):
super().__init__(
"Custom fields should be passed as a list of dictionaries in the form of [{'id': 1, 'value': 'foo'}]")
class ResourceRequirementsError(BaseRedmineError):
"""
Resource requires specific Redmine plugin(s) to function.
"""
def __init__(self, requirements):
reqs = []
for req in requirements:
if isinstance(req, (list, tuple)):
reqs.append(' >= '.join([req[0], '.'.join(map(str, req[1]))]))
else:
reqs.append(req)
super().__init__(f"The following requirements must be installed for resource to function: {', '.join(reqs)}")
class FileUrlError(BaseRedmineError):
"""
URL provided to download a file can't be parsed.
"""
def __init__(self):
super().__init__("URL provided to download a file can't be parsed")
class ForbiddenError(BaseRedmineError):
"""
Requested resource is forbidden.
"""
def __init__(self):
super().__init__('Requested resource is forbidden')
class JSONDecodeError(BaseRedmineError):
"""
Unable to decode received JSON.
"""
def __init__(self, response):
self.response = response
super().__init__(
'Unable to decode received JSON, you can inspect exception\'s '
'"response" attribute to find out what the response was')
class ExportNotSupported(BaseRedmineError):
"""
Export functionality not supported by resource.
"""
def __init__(self):
super().__init__('Export functionality not supported by resource')
class ExportFormatNotSupportedError(BaseRedmineError):
"""
The given format isn't supported by resource.
"""
def __init__(self):
super().__init__("The given format isn't supported by resource")
class HTTPProtocolError(BaseRedmineError):
"""
Wrong HTTP protocol usage.
"""
def __init__(self):
super().__init__('Protocol redirect detected, Redmine URL expects HTTPS, but code uses HTTP or vice versa')
class TimezoneError(BaseRedmineError):
"""
Timezone is neither a string, suitable for a strptime %z, nor is an instance of tzinfo class.
"""
def __init__(self):
super().__init__(
'Timezone has to be either a ±HHMM string, e.g. -0800 or +0545, or an instance of datetime.tzinfo class')
class EngineClassError(BaseRedmineError):
"""
Engine isn't a class or isn't a BaseEngine subclass.
"""
def __init__(self):
super().__init__("Engine isn't a class or isn't a BaseEngine subclass")
|