1use http::uri::InvalidUri;
2use label::Label;
3
4use crate::package::PackageRef;
5
6#[cfg(feature = "registry-config")]
7pub mod config;
8pub mod digest;
9pub mod label;
10pub mod metadata;
11pub mod package;
12pub mod registry;
13
14#[derive(Debug, thiserror::Error)]
15pub enum Error {
16 #[error("error interacting with cache: {0}")]
17 CacheError(#[source] anyhow::Error),
18 #[error("error reading config file: {0}")]
19 ConfigFileIoError(#[source] std::io::Error),
20 #[error("failed to get registry credentials: {0:#}")]
21 CredentialError(#[source] anyhow::Error),
22 #[error("malformed component: {0:#}")]
23 InvalidComponent(#[source] anyhow::Error),
24 #[error("malformed package: {0:#}")]
25 InvalidPackage(#[source] anyhow::Error),
26 #[error("invalid config: {0}")]
27 InvalidConfig(#[source] anyhow::Error),
28 #[error("invalid content: {0}")]
29 InvalidContent(String),
30 #[error("invalid content digest: {0}")]
31 InvalidContentDigest(String),
32 #[error("invalid package manifest: {0}")]
33 InvalidPackageManifest(String),
34 #[error("invalid package pattern: {0}")]
35 InvalidPackagePattern(String),
36 #[error("invalid label: {0}")]
37 InvalidLabel(#[from] label::InvalidLabel),
38 #[error("invalid package ref: {0}")]
39 InvalidPackageRef(String),
40 #[error("invalid registry: {0}")]
41 InvalidRegistry(#[from] InvalidUri),
42 #[error("invalid registry metadata: {0}")]
43 InvalidRegistryMetadata(#[source] anyhow::Error),
44 #[error("invalid version: {0}")]
45 InvalidVersion(#[from] semver::Error),
46 #[error("IO error: {0}")]
47 IoError(#[from] std::io::Error),
48 #[error("no registry configured for namespace {0:?}")]
49 NoRegistryForNamespace(Label),
50 #[error("Package not found")]
51 PackageNotFound,
52 #[error("registry error: {0:#}")]
53 RegistryError(#[source] anyhow::Error),
54 #[error("registry metadata error: {0:#}")]
55 RegistryMetadataError(#[source] anyhow::Error),
56 #[error("version not found: {0}")]
57 VersionNotFound(semver::Version),
58 #[error("{0}@{1} already exists in the registry")]
59 VersionAlreadyExists(PackageRef, semver::Version),
60 #[error(
61 "new version {new} is not semver-compatible with existing version {previous}: {source:#}"
62 )]
63 SemverIncompatible {
64 previous: semver::Version,
65 new: semver::Version,
66 #[source]
67 source: anyhow::Error,
68 },
69}