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