Coverage for /home/martinb/.local/share/virtualenvs/camcops/lib/python3.6/site-packages/wand/exceptions.py : 100%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1""":mod:`wand.exceptions` --- Errors and warnings
2~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4This module maps MagickWand API's errors and warnings to Python's native
5exceptions and warnings. You can catch all MagickWand errors using Python's
6natural way to catch errors.
8.. seealso::
10 `ImageMagick Exceptions <http://www.imagemagick.org/script/exception.php>`_
12.. versionadded:: 0.1.1
14.. versionchanged:: 0.5.8
15 Warning & Error Exceptions are now explicitly defined. Previously
16 ImageMagick domain-based errors were dynamically generated at runtime.
17"""
20class WandException(Exception):
21 """All Wand-related exceptions are derived from this class."""
24class BaseWarning(WandException, Warning):
25 """Base class for Wand-related warnings.
27 .. versionadded:: 0.4.4
29 """
32class BaseError(WandException):
33 """Base class for Wand-related errors.
35 .. versionadded:: 0.4.4
37 """
40class BaseFatalError(WandException):
41 """Base class for Wand-related fatal errors.
43 .. versionadded:: 0.4.4
45 """
48class WandLibraryVersionError(WandException):
49 """Base class for Wand-related ImageMagick version errors.
51 .. versionadded:: 0.3.2
53 """
56class WandRuntimeError(WandException, RuntimeError):
57 """Generic class for Wand-related runtime errors.
59 .. versionadded:: 0.5.2
60 """
63class ResourceLimitWarning(BaseWarning, MemoryError):
64 """A program resource is exhausted e.g. not enough memory."""
65 wand_error_code = 300
68class ResourceLimitError(BaseError, MemoryError):
69 """A program resource is exhausted e.g. not enough memory."""
70 wand_error_code = 400
73class ResourceLimitFatalError(BaseFatalError, MemoryError):
74 """A program resource is exhausted e.g. not enough memory."""
75 wand_error_code = 700
78class TypeWarning(BaseWarning):
79 """A font is unavailable; a substitution may have occurred."""
80 wand_error_code = 305
83class TypeError(BaseError):
84 """A font is unavailable; a substitution may have occurred."""
85 wand_error_code = 405
88class TypeFatalError(BaseFatalError):
89 """A font is unavailable; a substitution may have occurred."""
90 wand_error_code = 705
93class OptionWarning(BaseWarning):
94 """A command-line option was malformed."""
95 wand_error_code = 310
98class OptionError(BaseError):
99 """A command-line option was malformed."""
100 wand_error_code = 410
103class OptionFatalError(BaseFatalError):
104 """A command-line option was malformed."""
105 wand_error_code = 710
108class DelegateWarning(BaseWarning):
109 """An ImageMagick delegate failed to complete."""
110 wand_error_code = 315
113class DelegateError(BaseError):
114 """An ImageMagick delegate failed to complete."""
115 wand_error_code = 415
118class DelegateFatalError(BaseFatalError):
119 """An ImageMagick delegate failed to complete."""
120 wand_error_code = 715
123class MissingDelegateWarning(BaseWarning, ImportError):
124 """The image type can not be read or written because the appropriate;
125 delegate is missing."""
126 wand_error_code = 320
129class MissingDelegateError(BaseError, ImportError):
130 """The image type can not be read or written because the appropriate;
131 delegate is missing."""
132 wand_error_code = 420
135class MissingDelegateFatalError(BaseFatalError, ImportError):
136 """The image type can not be read or written because the appropriate;
137 delegate is missing."""
138 wand_error_code = 720
141class CorruptImageWarning(BaseWarning, ValueError):
142 """The image file may be corrupt."""
143 wand_error_code = 325
146class CorruptImageError(BaseError, ValueError):
147 """The image file may be corrupt."""
148 wand_error_code = 425
151class CorruptImageFatalError(BaseFatalError, ValueError):
152 """The image file may be corrupt."""
153 wand_error_code = 725
156class FileOpenWarning(BaseWarning, IOError):
157 """The image file could not be opened for reading or writing."""
158 wand_error_code = 330
161class FileOpenError(BaseError, IOError):
162 """The image file could not be opened for reading or writing."""
163 wand_error_code = 430
166class FileOpenFatalError(BaseFatalError, IOError):
167 """The image file could not be opened for reading or writing."""
168 wand_error_code = 730
171class BlobWarning(BaseWarning, IOError):
172 """A binary large object could not be allocated, read, or written."""
173 wand_error_code = 335
176class BlobError(BaseError, IOError):
177 """A binary large object could not be allocated, read, or written."""
178 wand_error_code = 435
181class BlobFatalError(BaseFatalError, IOError):
182 """A binary large object could not be allocated, read, or written."""
183 wand_error_code = 735
186class StreamWarning(BaseWarning, IOError):
187 """There was a problem reading or writing from a stream."""
188 wand_error_code = 340
191class StreamError(BaseError, IOError):
192 """There was a problem reading or writing from a stream."""
193 wand_error_code = 440
196class StreamFatalError(BaseFatalError, IOError):
197 """There was a problem reading or writing from a stream."""
198 wand_error_code = 740
201class CacheWarning(BaseWarning):
202 """Pixels could not be read or written to the pixel cache."""
203 wand_error_code = 345
206class CacheError(BaseError):
207 """Pixels could not be read or written to the pixel cache."""
208 wand_error_code = 445
211class CacheFatalError(BaseFatalError):
212 """Pixels could not be read or written to the pixel cache."""
213 wand_error_code = 745
216class CoderWarning(BaseWarning):
217 """There was a problem with an image coder."""
218 wand_error_code = 350
221class CoderError(BaseError):
222 """There was a problem with an image coder."""
223 wand_error_code = 450
226class CoderFatalError(BaseFatalError):
227 """There was a problem with an image coder."""
228 wand_error_code = 750
231class ModuleWarning(BaseWarning):
232 """There was a problem with an image module."""
233 wand_error_code = 355
236class ModuleError(BaseError):
237 """There was a problem with an image module."""
238 wand_error_code = 455
241class ModuleFatalError(BaseFatalError):
242 """There was a problem with an image module."""
243 wand_error_code = 755
246class DrawWarning(BaseWarning):
247 """A drawing operation failed."""
248 wand_error_code = 360
251class DrawError(BaseError):
252 """A drawing operation failed."""
253 wand_error_code = 460
256class DrawFatalError(BaseFatalError):
257 """A drawing operation failed."""
258 wand_error_code = 760
261class ImageWarning(BaseWarning):
262 """The operation could not complete due to an incompatible image."""
263 wand_error_code = 365
266class ImageError(BaseError):
267 """The operation could not complete due to an incompatible image."""
268 wand_error_code = 465
271class ImageFatalError(BaseFatalError):
272 """The operation could not complete due to an incompatible image."""
273 wand_error_code = 765
276class WandWarning(BaseWarning):
277 """There was a problem specific to the MagickWand API."""
278 wand_error_code = 370
281class WandError(BaseError):
282 """There was a problem specific to the MagickWand API."""
283 wand_error_code = 470
286class WandFatalError(BaseFatalError):
287 """There was a problem specific to the MagickWand API."""
288 wand_error_code = 770
291class RandomWarning(BaseWarning):
292 """There is a problem generating a true or pseudo-random number."""
293 wand_error_code = 375
296class RandomError(BaseError):
297 """There is a problem generating a true or pseudo-random number."""
298 wand_error_code = 475
301class RandomFatalError(BaseFatalError):
302 """There is a problem generating a true or pseudo-random number."""
303 wand_error_code = 775
306class XServerWarning(BaseWarning):
307 """An X resource is unavailable."""
308 wand_error_code = 380
311class XServerError(BaseError):
312 """An X resource is unavailable."""
313 wand_error_code = 480
316class XServerFatalError(BaseFatalError):
317 """An X resource is unavailable."""
318 wand_error_code = 780
321class MonitorWarning(BaseWarning):
322 """There was a problem activating the progress monitor."""
323 wand_error_code = 385
326class MonitorError(BaseError):
327 """There was a problem activating the progress monitor."""
328 wand_error_code = 485
331class MonitorFatalError(BaseFatalError):
332 """There was a problem activating the progress monitor."""
333 wand_error_code = 785
336class RegistryWarning(BaseWarning):
337 """There was a problem getting or setting the registry."""
338 wand_error_code = 390
341class RegistryError(BaseError):
342 """There was a problem getting or setting the registry."""
343 wand_error_code = 490
346class RegistryFatalError(BaseFatalError):
347 """There was a problem getting or setting the registry."""
348 wand_error_code = 790
351class ConfigureWarning(BaseWarning):
352 """There was a problem getting a configuration file."""
353 wand_error_code = 395
356class ConfigureError(BaseError):
357 """There was a problem getting a configuration file."""
358 wand_error_code = 495
361class ConfigureFatalError(BaseFatalError):
362 """There was a problem getting a configuration file."""
363 wand_error_code = 795
366class PolicyWarning(BaseWarning):
367 """A policy denies access to a delegate, coder, filter, path, or
368 resource."""
369 wand_error_code = 399
372class PolicyError(BaseError):
373 """A policy denies access to a delegate, coder, filter, path, or
374 resource."""
375 wand_error_code = 499
378class PolicyFatalError(BaseFatalError):
379 """A policy denies access to a delegate, coder, filter, path, or
380 resource."""
381 wand_error_code = 799
384#: (:class:`dict`) The dictionary of (code, exc_type).
385TYPE_MAP = {
386 300: ResourceLimitWarning,
387 305: TypeWarning,
388 310: OptionWarning,
389 315: DelegateWarning,
390 320: MissingDelegateWarning,
391 325: CorruptImageWarning,
392 330: FileOpenWarning,
393 335: BlobWarning,
394 340: StreamWarning,
395 345: CacheWarning,
396 350: CoderWarning,
397 355: ModuleWarning,
398 360: DrawWarning,
399 365: ImageWarning,
400 370: WandWarning,
401 375: RandomWarning,
402 380: XServerWarning,
403 385: MonitorWarning,
404 390: RegistryWarning,
405 395: ConfigureWarning,
406 399: PolicyWarning,
407 400: ResourceLimitError,
408 405: TypeError,
409 410: OptionError,
410 415: DelegateError,
411 420: MissingDelegateError,
412 425: CorruptImageError,
413 430: FileOpenError,
414 435: BlobError,
415 440: StreamError,
416 445: CacheError,
417 450: CoderError,
418 455: ModuleError,
419 460: DrawError,
420 465: ImageError,
421 470: WandError,
422 475: RandomError,
423 480: XServerError,
424 485: MonitorError,
425 490: RegistryError,
426 495: ConfigureError,
427 499: PolicyError,
428 700: ResourceLimitFatalError,
429 705: TypeFatalError,
430 710: OptionFatalError,
431 715: DelegateFatalError,
432 720: MissingDelegateFatalError,
433 725: CorruptImageFatalError,
434 730: FileOpenFatalError,
435 735: BlobFatalError,
436 740: StreamFatalError,
437 745: CacheFatalError,
438 750: CoderFatalError,
439 755: ModuleFatalError,
440 760: DrawFatalError,
441 765: ImageFatalError,
442 770: WandFatalError,
443 775: RandomFatalError,
444 780: XServerFatalError,
445 785: MonitorFatalError,
446 790: RegistryFatalError,
447 795: ConfigureFatalError,
448 799: PolicyFatalError,
449}