diff options
author | Florian Klink <flokli@flokli.de> | 2023-01-31T13·45+0100 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2023-01-31T15·16+0000 |
commit | 2d24c5f260945216ca01371d4120f5d53f08b2cd (patch) | |
tree | 5053bbffefd5a41241ab6ea27fafc290e44e665f /tvix/nix-compat/src/derivation/errors.rs | |
parent | 9e809e21ccb1768567fc2516c5526ad0cdd56df0 (diff) |
refactor(tvix/nix-compat): absorb //tvix/derivation r/5791
Put this in its src/derivation. Change-Id: Ic047ab1c2da555a833ee454e10ef60c77537b617 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7967 Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI Autosubmit: flokli <flokli@flokli.de>
Diffstat (limited to 'tvix/nix-compat/src/derivation/errors.rs')
-rw-r--r-- | tvix/nix-compat/src/derivation/errors.rs | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/tvix/nix-compat/src/derivation/errors.rs b/tvix/nix-compat/src/derivation/errors.rs new file mode 100644 index 000000000000..0dcad9a5345e --- /dev/null +++ b/tvix/nix-compat/src/derivation/errors.rs @@ -0,0 +1,56 @@ +use crate::{nixbase32::Nixbase32DecodeError, store_path::ParseStorePathError}; +use thiserror::Error; + +/// Errors that can occur during the validation of Derivation structs. +#[derive(Debug, Error, PartialEq)] +pub enum DerivationError { + // outputs + #[error("no outputs defined")] + NoOutputs(), + #[error("invalid output name: {0}")] + InvalidOutputName(String), + #[error("encountered fixed-output derivation, but more than 1 output in total")] + MoreThanOneOutputButFixed(), + #[error("invalid output name for fixed-output derivation: {0}")] + InvalidOutputNameForFixed(String), + #[error("unable to validate output {0}: {1}")] + InvalidOutput(String, OutputError), + // input derivation + #[error("unable to parse input derivation path {0}: {1}")] + InvalidInputDerivationPath(String, ParseStorePathError), + #[error("input derivation {0} doesn't end with .drv")] + InvalidInputDerivationPrefix(String), + #[error("input derivation {0} output names are empty")] + EmptyInputDerivationOutputNames(String), + #[error("input derivation {0} output name {1} is invalid")] + InvalidInputDerivationOutputName(String, String), + + // input sources + #[error("unable to parse input sources path {0}: {1}")] + InvalidInputSourcesPath(String, ParseStorePathError), + + // platform + #[error("invalid platform field: {0}")] + InvalidPlatform(String), + + // builder + #[error("invalid builder field: {0}")] + InvalidBuilder(String), + + // environment + #[error("invalid environment key {0}")] + InvalidEnvironmentKey(String), +} + +/// Errors that can occur during the validation of a specific [Output] of a [Derviation]. +#[derive(Debug, Error, PartialEq)] +pub enum OutputError { + #[error("Invalid ouput path {0}: {1}")] + InvalidOutputPath(String, ParseStorePathError), + #[error("Invalid hash encoding: {0}")] + InvalidHashEncoding(String, Nixbase32DecodeError), + #[error("Invalid hash algo: {0}")] + InvalidHashAlgo(String), + #[error("Invalid Digest size {0} for algo {1}")] + InvalidDigestSizeForAlgo(usize, String), +} |