Errors¶
Exceptions raised by libphash.
Every failure of the C library becomes a subclass of :class:PhashError, chosen by its
ph_error_t code. The classes also derive from the built-in exception a Python
programmer would reach for: an unreadable file is an :class:OSError (with errno,
so except FileNotFoundError works), a bad argument a :class:ValueError, a failed
allocation a :class:MemoryError.
PhashError ¶
Bases: Exception
Base class of every libphash error.
Attributes:
code: the ph_error_t value, or 0 for an error raised by the binding itself.
code_name: the C name of the code ("PH_ERR_IO"), or "".
detail: the C library's description of this failure (for loading: the path and
the reason), or "".
ImageIOError ¶
Bases: PhashError, OSError
The path could not be used as an image source (PH_ERR_IO).
errno and filename are filled in when the cause can be told (a missing file,
a directory, no permission), so the matching :class:OSError subclass catches it:
except FileNotFoundError sees a missing image file.