1use fuchsia_hash::ParseHashError;
6use fuchsia_pkg::{PackagePathSegmentError, ParsePackagePathError};
7use std::io;
8use std::str::Utf8Error;
9use thiserror::Error;
10
11#[derive(Debug, Error)]
12pub enum PathHashMappingError {
13 #[error("entry has no '=': '{entry:?}'")]
14 EntryHasNoEqualsSign { entry: String },
15
16 #[error("io error")]
17 IoError(#[from] io::Error),
18
19 #[error("invalid hash")]
20 ParseHash(#[from] ParseHashError),
21
22 #[error("invalid package path")]
23 ParsePackagePath(#[from] ParsePackagePathError),
24}
25
26#[derive(Debug, Error)]
27pub enum AllowListError {
28 #[error("encoding error")]
29 Encoding(#[from] Utf8Error),
30
31 #[error("invalid package name")]
32 PackageName(#[from] PackagePathSegmentError),
33}
34
35#[derive(Debug, Error)]
36pub enum CachePackagesInitError {
37 #[error("while reading data/cache_packages.json file")]
38 ReadCachePackagesJson(#[source] package_directory::ReadFileError),
39
40 #[error("while reading data/cache_packages file")]
41 ReadCachePackages(#[source] package_directory::ReadFileError),
42
43 #[error("while processing data/cache_packages")]
44 ProcessingCachePackages(#[from] PathHashMappingError),
45
46 #[error("while parsing data/cache_packages")]
47 ParseConfig(#[from] fuchsia_url::errors::ParseError),
48
49 #[error("json parsing error while reading packages config")]
50 JsonError(#[source] serde_json::error::Error),
51
52 #[error("packages config version not supported: '{0:?}'")]
53 VersionNotSupported(String),
54
55 #[error("non empty cache_packages.json should have at least 1 package")]
56 NoCachePackages,
57}
58
59#[derive(Debug, Error)]
60pub enum StaticPackagesInitError {
61 #[error("while reading data/static_packages file")]
62 ReadStaticPackages(#[source] package_directory::ReadFileError),
63
64 #[error("while processing data/static_packages")]
65 ProcessingStaticPackages(#[source] PathHashMappingError),
66}