Exceptions

Exceptions are defined in three different modules in the craft_parts package.

General errors

Exceptions for general errors are defined in the craft_parts.errors module.

Craft parts errors.

exception craft_parts.errors.CallbackRegistrationError(message)[source]

Bases: PartsError

Error in callback function registration.

Parameters:

message (str) – the error message.

exception craft_parts.errors.CopyFileNotFound(name)[source]

Bases: PartsError

An attempt was made to copy a file that doesn’t exist.

Parameters:

name (str) – The file name.

exception craft_parts.errors.CopyTreeError(message)[source]

Bases: PartsError

Failed to copy or link a file tree.

Parameters:

message (str) – The error message.

exception craft_parts.errors.DebError(deb_path, command, exit_code)[source]

Bases: PartsError

A “deb”-related command failed.

Parameters:
  • deb_path (Path)

  • command (list[str])

  • exit_code (int)

exception craft_parts.errors.FeatureError(message, details=None)[source]

Bases: PartsError

A feature is not configured as expected.

Parameters:
  • message (str)

  • details (Optional[str])

exception craft_parts.errors.FileOrganizeError(*, part_name, message)[source]

Bases: PartsError

Failed to organize a file layout.

Parameters:
  • part_name (str) – The name of the part being processed.

  • message (str) – The error message.

exception craft_parts.errors.FilesetConflict(conflicting_files)[source]

Bases: PartsError

Inconsistent stage to prime filtering.

Parameters:

conflicting_files (set[str]) – A set containing the conflicting file names.

exception craft_parts.errors.FilesetError(*, name, message)[source]

Bases: PartsError

An invalid fileset operation was performed.

Parameters:
  • name (str) – The name of the fileset.

  • message (str) – The error message.

exception craft_parts.errors.InvalidAction(message)[source]

Bases: PartsError

An attempt was made to execute an action with invalid parameters.

Parameters:

message (str) – The error message.

exception craft_parts.errors.InvalidApplicationName(name)[source]

Bases: PartsError

The application name contains invalid characters.

Parameters:

name (str) – The invalid application name.

exception craft_parts.errors.InvalidArchitecture(arch_name)[source]

Bases: PartsError

The machine architecture is not supported.

Parameters:

arch_name (str) – The unsupported architecture name.

exception craft_parts.errors.InvalidControlAPICall(*, part_name, scriptlet_name, message)[source]

Bases: PartsError

A control API call was made with invalid parameters.

Parameters:
  • part_name (str) – The name of the part being processed.

  • scriptlet_name (str) – The name of the scriptlet that originated the call.

  • message (str) – The error message.

exception craft_parts.errors.InvalidPartName(part_name)[source]

Bases: PartsError

An operation was requested on a part that’s not in the parts specification.

Parameters:

part_name (str) – The invalid part name.

exception craft_parts.errors.InvalidPlugin(plugin_name, *, part_name)[source]

Bases: PartsError

A request was made to use a plugin that’s not registered.

Parameters:
  • plugin_name (str) – The invalid plugin name.”

  • part_name (str) – The name of the part defining the invalid plugin.

exception craft_parts.errors.OsReleaseCodenameError[source]

Bases: PartsError

Failed to determine the host operating system version codename.

exception craft_parts.errors.OsReleaseIdError[source]

Bases: PartsError

Failed to determine the host operating system identification string.

exception craft_parts.errors.OsReleaseNameError[source]

Bases: PartsError

Failed to determine the host operating system name.

exception craft_parts.errors.OsReleaseVersionIdError[source]

Bases: PartsError

Failed to determine the host operating system version.

exception craft_parts.errors.OverlayPackageNotFound(*, part_name, package_name)[source]

Bases: PartsError

Failed to install an overlay package.

Parameters:
  • part_name (str) – The name of the part being processed.

  • message – the error message.

  • package_name (str)

exception craft_parts.errors.OverlayPermissionError[source]

Bases: PartsError

A project using overlays was processed by a non-privileged user.

exception craft_parts.errors.OverlayPlatformError[source]

Bases: PartsError

A project using overlays was processed on a non-Linux platform.

exception craft_parts.errors.PartDependencyCycle[source]

Bases: PartsError

A dependency cycle has been detected in the parts definition.

exception craft_parts.errors.PartFilesConflict(*, part_name, other_part_name, conflicting_files, partition=None)[source]

Bases: PartsError

Different parts list the same files with different contents.

Parameters:
  • part_name (str) – The name of the part being processed.

  • other_part_name (str) – The name of the conflicting part.

  • conflicting_files (list[str]) – The list of conflicting files.

  • partition (Optional[str]) – Optional name of the partition where the conflict occurred.

exception craft_parts.errors.PartSpecificationError(*, part_name, message)[source]

Bases: PartsError

A part was not correctly specified.

Parameters:
  • part_name (str) – The name of the part being processed.

  • message (str) – The error message.

classmethod from_validation_error(*, part_name, error_list)[source]

Create a PartSpecificationError from a pydantic error list.

Parameters:
  • part_name (str) – The name of the part being processed.

  • error_list (list[ErrorDict]) – A list of dictionaries containing pydantic error definitions.

Return type:

PartSpecificationError

exception craft_parts.errors.PartitionError(brief, *, details=None, resolution=None)[source]

Bases: PartsError

Errors related to partitions.

Parameters:
  • brief (str)

  • details (Optional[str])

  • resolution (Optional[str])

exception craft_parts.errors.PartitionNotFound(partition_name, partitions)[source]

Bases: PartitionUsageError

A partition has been specified that does not exist.

Parameters:
  • partition_name (str) – The name of the partition that does not exist.

  • partitions (Iterable[str]) – Iterable of the names of valid partitions.

exception craft_parts.errors.PartitionUsageError(error_list, partitions, brief=None)[source]

Bases: PartitionError

Error for a list of invalid partition usages.

Parameters:
  • error_list (Iterable[str]) – Iterable of strings describing the invalid usages.

  • partitions (Iterable[str] | None) – Iterable of the names of valid partitions.

  • brief (Optional[str]) – Override brief message.

exception craft_parts.errors.PartitionUsageWarning(warning_list)[source]

Bases: PartitionError, Warning

Warnings for possibly invalid usages of partitions.

Parameters:

warning_list (Iterable[str]) – Iterable of strings describing the misuses.

exception craft_parts.errors.PartsError(brief, details=None, resolution=None, doc_slug=None)[source]

Bases: Exception

Unexpected error.

Parameters:
  • brief (str) – Brief description of error.

  • details (Optional[str]) – Detailed information.

  • resolution (Optional[str]) – Recommendation, if any.

  • doc_slug (Optional[str]) – Reusable documentation slug for consumers adopting the Craft Parts documentation.

exception craft_parts.errors.PluginBuildError(*, part_name, plugin_name)[source]

Bases: PartsError

Plugin build script failed at runtime.

Parameters:
  • part_name (str) – The name of the part being processed.

  • plugin_name (str) – The name of the plugin being processed.

exception craft_parts.errors.PluginCleanError(*, part_name)[source]

Bases: PartsError

Script to clean strict build preparation failed at runtime.

Parameters:

part_name (str) – The name of the part being processed.

exception craft_parts.errors.PluginEnvironmentValidationError(*, part_name, reason)[source]

Bases: PartsError

Plugin environment validation failed at runtime.

Parameters:
  • part_name (str) – The name of the part being processed.

  • reason (str)

exception craft_parts.errors.PluginNotStrict(plugin_name, *, part_name)[source]

Bases: PartsError

A request was made to use a plugin that’s not strict.

Parameters:
  • plugin_name (str) – The plugin name.

  • part_name (str) – The name of the part defining the plugin.

exception craft_parts.errors.PluginPullError(*, part_name)[source]

Bases: PartsError

Plugin pull script failed at runtime.

Parameters:

part_name (str) – The name of the part being processed.

exception craft_parts.errors.ScriptletRunError(*, part_name, scriptlet_name, exit_code)[source]

Bases: PartsError

A scriptlet execution failed.

Parameters:
  • part_name (str) – The name of the part being processed.

  • scriptlet_name (str) – The name of the scriptlet that failed to execute.

  • exit_code (int) – The execution error code.

exception craft_parts.errors.StageFilesConflict(*, part_name, conflicting_files)[source]

Bases: PartsError

Files from a part conflict with files already being staged.

Parameters:
  • part_name (str) – The name of the part being processed.

  • conflicting_files (list[str]) – The list of confictling files.

exception craft_parts.errors.StagePackageNotFound(*, part_name, package_name)[source]

Bases: PartsError

Failed to install a stage package.

Parameters:
  • part_name (str) – The name of the part being processed.

  • package_name (str) – The name of the package.

exception craft_parts.errors.UndefinedPlugin(*, part_name)[source]

Bases: PartsError

The part didn’t define a plugin and the part name is not a valid plugin name.

Parameters:

part_name (str) – The name of the part with no plugin definition.

exception craft_parts.errors.XAttributeError(key, path, is_write=False)[source]

Bases: PartsError

Failed to read or write an extended attribute.

Parameters:
  • action – The action being performed.

  • key (str) – The extended attribute key.

  • path (str) – The file path.

  • is_write (bool) – Whether this is an attribute write operation.

exception craft_parts.errors.XAttributeTooLong(key, value, path)[source]

Bases: PartsError

Failed to write an extended attribute because key and/or value is too long.

Parameters:
  • key (str) – The extended attribute key.

  • value (str) – The extended attribute value.

  • path (str) – The file path.

Source handling errors

Exceptions for errors related to source handling are defined in the craft_parts.sources.errors module.

Source handler error definitions.

exception craft_parts.sources.errors.ChecksumMismatch(*, expected, obtained)[source]

Bases: SourceError

A checksum doesn’t match the expected value.

Parameters:
  • expected (str) – The expected checksum.

  • obtained (str) – The actual checksum.

exception craft_parts.sources.errors.HttpRequestError(*, status_code, reason, source)[source]

Bases: SourceError

HTTP error occurred during request processing.

Parameters:
  • status_code (int) – Request status code.

  • reason (str) – Text explaining status code.

  • source (str) – The source defined for the part.

exception craft_parts.sources.errors.IncompatibleSourceOptions(source_type, options)[source]

Bases: SourceError

Source specified options that cannot be used at the same time.

Parameters:
  • source_type (str) – The part’s source type.

  • options (list[str]) – The list of incompatible source options.

exception craft_parts.sources.errors.InvalidRpmPackage(rpm_file)[source]

Bases: SourceError

An rpm package is invalid.

Parameters:

rpm_file (str) – The filename.

exception craft_parts.sources.errors.InvalidSnapPackage(snap_file)[source]

Bases: SourceError

A snap package is invalid.

Parameters:

snap_file (str) – The snap file name.

exception craft_parts.sources.errors.InvalidSourceOption(*, source_type, option)[source]

Bases: SourceError

A source option is not allowed for the given source type.

Parameters:
  • source_type (str) – The part’s source type.

  • option (str) – The invalid source option.

exception craft_parts.sources.errors.InvalidSourceOptions(*, source_type, options)[source]

Bases: SourceError

A source option is not allowed for the given source type.

Parameters:
  • source_type (str) – The part’s source type.

  • options (list[str]) – The invalid source options.

exception craft_parts.sources.errors.InvalidSourceType(source)[source]

Bases: SourceError

Failed to determine a source type.

Parameters:

source (str) – The source defined for the part.

exception craft_parts.sources.errors.NetworkRequestError(message, *, source=None)[source]

Bases: SourceError

A network request operation failed.

Parameters:
  • message (str) – The error message.

  • source (Optional[str]) – URL of unreachable source.

exception craft_parts.sources.errors.PullError(*, command, exit_code)[source]

Bases: SourceError

Failed pulling source.

Parameters:
  • command (Sequence) – The command used to pull the source.

  • exit_code (int) – The command exit code.

exception craft_parts.sources.errors.SourceError(brief, details=None, resolution=None, doc_slug=None)[source]

Bases: PartsError

Base class for source handler errors.

Parameters:
  • brief (str)

  • details (Optional[str])

  • resolution (Optional[str])

  • doc_slug (Optional[str])

exception craft_parts.sources.errors.SourceNotFound(source)[source]

Bases: SourceError

Failed to retrieve a source.

Parameters:

source (str) – The source defined for the part.

exception craft_parts.sources.errors.SourceUpdateUnsupported(name)[source]

Bases: SourceError

The source handler doesn’t support updating.

Parameters:

name (str) – The source type.

exception craft_parts.sources.errors.VCSError(message)[source]

Bases: SourceError

A version control system command failed.

Parameters:

message (str)

Package handling errors

Exceptions for errors related to package handling are defined in the craft_parts.packages.errors module.

Exceptions raised by the packages handling subsystem.

exception craft_parts.packages.errors.BuildPackageNotFound(package)[source]

Bases: PackagesError

A package listed in ‘build-packages’ was not found.

Parameters:

package (str) – The name of the missing package.

exception craft_parts.packages.errors.BuildPackagesNotInstalled(*, packages)[source]

Bases: PackagesError

Could not install all requested build packages.

Parameters:

packages (Sequence[str]) – The packages to install.

exception craft_parts.packages.errors.ChiselError(*, slices, output)[source]

Bases: PackagesError

A “chisel”-related command failed.

Parameters:
  • slices (list[str])

  • output (str)

exception craft_parts.packages.errors.FileProviderNotFound(*, file_path)[source]

Bases: PackagesError

A file is not provided by any package.

Parameters:

file_path (str) – The file path.

exception craft_parts.packages.errors.PackageBackendNotSupported(backend)[source]

Bases: PartsError

Requested package resolved not supported on this host.

Parameters:

backend (str)

exception craft_parts.packages.errors.PackageBroken(package_name, *, deps)[source]

Bases: PackagesError

Package has unmet dependencies.

Parameters:
  • package_name (str) – The name of the package with unmet dependencies.

  • deps (Sequence[str]) – The list of unmet dependencies.

exception craft_parts.packages.errors.PackageFetchError(message)[source]

Bases: PackagesError

Failed to fetch package from remote repository.

Parameters:

message (str) – The error message.

exception craft_parts.packages.errors.PackageListRefreshError(message)[source]

Bases: PackagesError

Failed to refresh the list of available packages.

Parameters:

message (str) – The error message.

exception craft_parts.packages.errors.PackageNotFound(package_name)[source]

Bases: PackagesError

Requested package doesn’t exist in the remote repository.

Parameters:

package_name (str) – The name of the missing package.

exception craft_parts.packages.errors.PackagesDownloadError(*, packages)[source]

Bases: PackagesError

Failed to download packages from remote repository.

Parameters:

packages (Sequence[str]) – The packages to download.

exception craft_parts.packages.errors.PackagesError(brief, details=None, resolution=None, doc_slug=None)[source]

Bases: PartsError

Base class for package handler errors.

Parameters:
  • brief (str)

  • details (Optional[str])

  • resolution (Optional[str])

  • doc_slug (Optional[str])

exception craft_parts.packages.errors.PackagesNotFound(packages)[source]

Bases: PackagesError

Requested package doesn’t exist in the remote repository.

Parameters:
  • package_name – The names of the missing packages.

  • packages (Sequence[str])

exception craft_parts.packages.errors.SnapDownloadError(*, snap_name, snap_channel)[source]

Bases: PackagesError

Failed to download a snap.

Parameters:
  • snap_name (str) – The snap name.

  • snap_channel (str) – The snap channel.

exception craft_parts.packages.errors.SnapGetAssertionError(*, assertion_params)[source]

Bases: PackagesError

Failed to retrieve snap assertion.

Parameters:

assertion_params (Sequence[str]) – The snap assertion parameters.

exception craft_parts.packages.errors.SnapInstallError(*, snap_name, snap_channel)[source]

Bases: PackagesError

Failed to install a snap.

Parameters:
  • snap_name (str) – The snap name.

  • snap_channel (str) – The snap channel.

exception craft_parts.packages.errors.SnapRefreshError(*, snap_name, snap_channel)[source]

Bases: PackagesError

Failed to refresh a snap.

Parameters:
  • snap_name (str) – The snap name.

  • snap_channel (str) – The snap channel.

exception craft_parts.packages.errors.SnapUnavailable(*, snap_name, snap_channel)[source]

Bases: PackagesError

Failed to install or refresh a snap.

Parameters:
  • snap_name (str) – The snap name.

  • snap_channel (str) – The snap channel.

exception craft_parts.packages.errors.SnapdConnectionError(*, snap_name, url)[source]

Bases: PackagesError

Failed to connect to snapd.

Parameters:
  • snap_name (str) – The snap name.

  • url (str) – The failed connection URL.

exception craft_parts.packages.errors.UnpackError(package)[source]

Bases: PackagesError

Error unpacking stage package.

Parameters:

package (str) – The package that failed to unpack.