tvl-depot/tvix/cli/src/errors.rs
Florian Klink 99d5cf822a refactor(tvix/cli): use nixhash module for output hash calculation
This covers all the weird corner cases.

Change-Id: I85637e82e8929828064ab562dc8a1c8bf161fffa
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7991
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
2023-02-01 15:29:48 +00:00

28 lines
1 KiB
Rust

use nix_compat::{derivation::DerivationError, nixhash};
use std::rc::Rc;
use thiserror::Error;
/// Errors related to derivation construction
#[derive(Debug, Error)]
pub enum Error {
#[error("an output with the name '{0}' is already defined")]
DuplicateOutput(String),
#[error("fixed-output derivations can only have the default `out`-output")]
ConflictingOutputTypes,
#[error("the environment variable '{0}' has already been set in this derivation")]
DuplicateEnvVar(String),
#[error("the environment variable '{0}' shadows the name of an output")]
ShadowedOutput(String),
#[error("invalid derivation parameters: {0}")]
InvalidDerivation(DerivationError),
#[error("invalid output hash: {0}")]
InvalidOutputHash(nixhash::Error),
#[error("invalid output hash mode: '{0}', only 'recursive' and 'flat` are supported")]
InvalidOutputHashMode(String),
}
impl From<Error> for tvix_eval::ErrorKind {
fn from(err: Error) -> Self {
tvix_eval::ErrorKind::TvixError(Rc::new(err))
}
}