nix_compat/derivation/
errors.rs

1//! Contains [DerivationError], exported as [crate::derivation::DerivationError]
2use crate::store_path;
3use thiserror::Error;
4
5use super::CAHash;
6
7/// Errors that can occur during the validation of Derivation structs.
8#[derive(Debug, Error, PartialEq)]
9pub enum DerivationError {
10    // outputs
11    #[error("no outputs defined")]
12    NoOutputs(),
13    #[error("invalid output name: {0}")]
14    InvalidOutputName(String),
15    #[error("encountered fixed-output derivation, but more than 1 output in total")]
16    MoreThanOneOutputButFixed(),
17    #[error("invalid output name for fixed-output derivation: {0}")]
18    InvalidOutputNameForFixed(String),
19    #[error("unable to validate output {0}: {1}")]
20    InvalidOutput(String, OutputError),
21    #[error("unable to validate output {0}: {1}")]
22    InvalidOutputDerivationPath(String, store_path::BuildStorePathError),
23    // input derivation
24    #[error("unable to parse input derivation path {0}: {1}")]
25    InvalidInputDerivationPath(String, store_path::Error),
26    #[error("input derivation {0} doesn't end with .drv")]
27    InvalidInputDerivationPrefix(String),
28    #[error("input derivation {0} output names are empty")]
29    EmptyInputDerivationOutputNames(String),
30    #[error("input derivation {0} output name {1} is invalid")]
31    InvalidInputDerivationOutputName(String, String),
32
33    // input sources
34    #[error("unable to parse input sources path {0}: {1}")]
35    InvalidInputSourcesPath(String, store_path::Error),
36
37    // platform
38    #[error("invalid platform field: {0}")]
39    InvalidPlatform(String),
40
41    // builder
42    #[error("invalid builder field: {0}")]
43    InvalidBuilder(String),
44
45    // environment
46    #[error("invalid environment key {0}")]
47    InvalidEnvironmentKey(String),
48}
49
50/// Errors that can occur during the validation of a specific
51// [crate::derivation::Output] of a [crate::derivation::Derviation].
52#[derive(Debug, Error, PartialEq)]
53pub enum OutputError {
54    #[error("Invalid output path {0}: {1}")]
55    InvalidOutputPath(String, store_path::Error),
56    #[error("Missing output path")]
57    MissingOutputPath,
58    #[error("Invalid CAHash: {:?}", .0)]
59    InvalidCAHash(CAHash),
60}