16. API - picamera.exc Module

This module defines the exceptions used by picamera. All exception classes utilize multiple inheritance in order to make testing for exception types more intuitive. For example, PiCameraValueError derives from both PiCameraError and ValueError. Hence it will be caught by blocks intended to catch any error specific to the picamera library:

    camera.brightness = int(some_user_value)
except PiCameraError:
    print('Something went wrong with the camera')

Or by blocks intended to catch value errors:

    camera.contrast = int(some_user_value)
except ValueError:
    print('Invalid value')


All classes in this module are available from the picamera namespace without having to import picamera.streams directly.

The following classes are defined in the module:

exception picamera.exc.PiCameraWarning[source]

Base class for PiCamera warnings.

exception picamera.exc.PiCameraDeprecated[source]

Raised when deprecated functionality in picamera is used.

exception picamera.exc.PiCameraFallback[source]

Raised when picamera has to fallback on old functionality.

exception picamera.exc.PiCameraError[source]

Base class for PiCamera errors.

exception picamera.exc.PiCameraValueError[source]

Raised when an invalid value is fed to a PiCamera object.

exception picamera.exc.PiCameraRuntimeError[source]

Raised when an invalid sequence of operations is attempted with a PiCamera object.

exception picamera.exc.PiCameraClosed[source]

Raised when a method is called on a camera which has already been closed.

exception picamera.exc.PiCameraNotRecording[source]

Raised when stop_recording() or split_recording() are called against a port which has no recording active.

exception picamera.exc.PiCameraAlreadyRecording[source]

Raised when start_recording() or record_sequence() are called against a port which already has an active recording.

exception picamera.exc.PiCameraMMALError(status, prefix='')[source]

Raised when an MMAL operation fails for whatever reason.

picamera.exc.mmal_check(status, prefix='')[source]

Checks the return status of an mmal call and raises an exception on failure.

The status parameter is the result of an MMAL call. If status is anything other than MMAL_SUCCESS, a PiCameraMMALError exception is raised. The optional prefix parameter specifies a prefix message to place at the start of the exception’s message to provide some context.