Exceptions

The bundle read/write and signing exceptions on this page derive from BundleError. Catch that base class when a problem reading, writing, signing, or verifying a bundle should stop your operation. Catch a subclass when you want to react to one kind of problem, such as an attachment whose hash does not match its contents.

Not every exception this package raises is a BundleError. Reading an element’s value can raise AttachmentContent or NoContent, which derive from ValueError. FileIntegrityError derives directly from Exception. Catch those separately when you read element values or check file hashes.

Bundle read/write exceptions

exception momotor.bundles.BundleError

Base class for all exceptions raised by the bundles module.

exception momotor.bundles.BundleHashError

Raised when a bundle attachment hash does not match the attachment content.

This is a subclass of BundleError.

exception momotor.bundles.BundleFormatError

Raised when a bundle is not valid.

This is a subclass of BundleError.

exception momotor.bundles.InvalidRefError

Raised when a ref attribute is invalid.

This is a subclass of BundleFormatError.

exception momotor.bundles.InvalidBundle

Raised when a bundle is invalid.

This is a subclass of BundleFormatError.

exception momotor.bundles.BundleLoadError

Raised when a bundle cannot be loaded.

This is a subclass of BundleError.

Signing exceptions

Added in version 9.0.0.

Signing and verification raise these subclasses of BundleError:

See Bundle verification for when each one occurs and how verification reports failures without raising.

Internal exceptions

These exceptions support the attachment and parsing internals and do not derive from BundleError. Most stay inside the package. AttachmentContent and NoContent can reach your code when you read an element’s value, as described above.

exception momotor.bundles.elements.content.AttachmentContent

Raised when the content is in an attachment.

Subclass of ValueError. This exception is raised when trying to access the value property of an element that has an external attachment. Its path is stored in src.

exception momotor.bundles.elements.content.NoContent

Raised when no content was provided.

Subclass of ValueError. This exception is raised when trying to access the value property of an element that has no content set.

exception momotor.bundles.elements.files.FileIntegrityError

Raised when an attachment fails hash verification

exception momotor.bundles.mixins.attachments.ZippedAttachment

Raised when trying to access a file using a filesystem path in a zipped bundle.

This exception occurs when attempting to get the absolute path of an attachment that exists within a ZIP file, since ZIP contents don’t have direct filesystem paths.

exception momotor.bundles.parsers.handlers.exceptions.ValidationError

Raised when an XML validation error occurs

This internal exception in converted to a BundleFormatError before being thrown to the caller