Skip to main content

nix_index/
errors.rs

1use std::{io, path::PathBuf};
2
3use thiserror::Error;
4
5use crate::{hydra, nixpkgs, package::StorePath};
6
7#[derive(Error, Debug)]
8pub enum Error {
9    #[error("querying available packages failed: {source}")]
10    QueryPackages {
11        #[source]
12        source: nixpkgs::Error,
13    },
14    #[error("fetching the file listing for store path '{path}' failed: {source}")]
15    FetchFiles {
16        path: StorePath,
17        #[source]
18        source: hydra::Error,
19    },
20    #[error("fetching the references of store path '{path}' failed: {source}")]
21    FetchReferences {
22        path: StorePath,
23        #[source]
24        source: hydra::Error,
25    },
26    #[error("reading the paths.cache file failed: {source}")]
27    LoadPathsCache {
28        #[source]
29        source: io::Error,
30    },
31    #[error("parsing the paths.cache file failed: {source}")]
32    ParsePathsCache {
33        #[source]
34        source: bincode::error::DecodeError,
35    },
36    #[error("writing the paths.cache file failed: {source}")]
37    WritePathsCache {
38        #[source]
39        source: Box<dyn std::error::Error>,
40    },
41    #[error("creating the database at '{path:?}' failed: {source}")]
42    CreateDatabase {
43        path: PathBuf,
44        #[source]
45        source: Box<dyn std::error::Error>,
46    },
47    #[error("creating the directory for the database at '{path:?}' failed: {source}")]
48    CreateDatabaseDir {
49        path: PathBuf,
50        #[source]
51        source: io::Error,
52    },
53    #[error("writing to the database '{path:?}' failed: {source}")]
54    WriteDatabase {
55        path: PathBuf,
56        #[source]
57        source: io::Error,
58    },
59    #[error("Can not parse proxy settings: {0}")]
60    ParseProxy(#[from] crate::hydra::Error),
61}
62
63pub type Result<T> = std::result::Result<T, Error>;