Errors¶
General Behavior¶
When BasswoodAV encounters an FFmpeg error, it raises an appropriate exception.
FFmpeg has a couple dozen of its own error types which we represent via Error Exception Classes.
FFmpeg will also return more typical errors such as ENOENT
or EAGAIN
,
which we do our best to translate to extensions of the builtin exceptions
as defined by
PEP 3151.
Error Exception Classes¶
BasswoodAV raises the typical builtin exceptions within its own codebase, but things get a little more complex when it comes to translating FFmpeg errors.
There are two competing ideas that have influenced the final design:
We want every exception that originates within FFmpeg to inherit from a common
FFmpegError
exception;We want to use the builtin exceptions whenever possible.
As such, BasswoodAV effectively shadows as much of the builtin exception hierarchy as
it requires, extending from both the builtins and from FFmpegError
.
Therefore, an argument error within FFmpeg will raise a av.error.ValueError
, which
can be caught via either FFmpegError
or ValueError
. All of these
exceptions expose the typical errno
and strerror
attributes, as well as some
BasswoodAV extensions such as FFmpegError.log
.
All of these exceptions are available on the top-level av
package, e.g.:
try:
do_something()
except av.FilterNotFoundError:
handle_error()
- class av.FFmpegError(code, message, filename=None, log=None)¶
Bases:
Exception
Exception class for errors from within FFmpeg.
- errno¶
FFmpeg’s integer error code.
- strerror¶
FFmpeg’s error message.
- filename¶
The filename that was being operated on (if available).
- log¶
The tuple from
av.logging.get_last_log()
, orNone
.