Skip to main content

aube_linker/
error.rs

1use std::path::PathBuf;
2
3#[derive(Debug, thiserror::Error, miette::Diagnostic)]
4pub enum Error {
5    #[error("I/O error at {0}: {1}")]
6    Io(PathBuf, std::io::Error),
7    #[error("file error: {0}")]
8    Xx(String),
9    #[error("failed to link {0} -> {1}: {2}")]
10    #[diagnostic(code(ERR_AUBE_LINK_FAILED))]
11    Link(PathBuf, PathBuf, String),
12    #[error("failed to apply patch for {0}: {1}")]
13    #[diagnostic(code(ERR_AUBE_PATCH_FAILED))]
14    Patch(String, String),
15    #[error(
16        "internal: missing package index for {0} — caller skipped `load_index` but the package wasn't already materialized"
17    )]
18    #[diagnostic(code(ERR_AUBE_MISSING_PACKAGE_INDEX))]
19    MissingPackageIndex(String),
20    #[error("refusing to materialize unsafe index key: {0:?}")]
21    #[diagnostic(code(ERR_AUBE_UNSAFE_INDEX_KEY))]
22    UnsafeIndexKey(String),
23    #[error("refusing to create node_modules entry for unsafe package name: {0:?}")]
24    #[diagnostic(code(ERR_AUBE_UNSAFE_PACKAGE_NAME))]
25    UnsafePackageName(String),
26    #[error("refusing to use a modules directory that is not inside the project: {0}")]
27    #[diagnostic(code(ERR_AUBE_UNSAFE_MODULES_DIR))]
28    UnsafeModulesDir(PathBuf),
29    #[error(
30        "cached package index references a missing CAS shard at {store_path} (file: {rel_path:?}). The store and its index cache are out of sync — rerun the install to re-fetch the tarball."
31    )]
32    #[diagnostic(code(ERR_AUBE_MISSING_STORE_FILE))]
33    MissingStoreFile {
34        store_path: PathBuf,
35        rel_path: String,
36    },
37}