about summary refs log tree commit diff
path: root/tvix/derivation/src/errors.rs
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2023-01-16T14·24+0100
committerflokli <flokli@flokli.de>2023-01-16T23·04+0000
commitd644ed389aab967a276c39b349a8d266a1aee889 (patch)
treed8fa216184906fcfb9db11ff7aae5010d64061bf /tvix/derivation/src/errors.rs
parent95cad95b9333214df90d6002e51c7ae34910fa7e (diff)
refactor(tvix/derivation): expose proper ValidateDerivationError r/5668
Use proper errors, instead of anyhow.

Change-Id: I6db14c72a6319b389b0136aac7b84f50a30fb366
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7847
Autosubmit: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
Diffstat (limited to 'tvix/derivation/src/errors.rs')
-rw-r--r--tvix/derivation/src/errors.rs44
1 files changed, 44 insertions, 0 deletions
diff --git a/tvix/derivation/src/errors.rs b/tvix/derivation/src/errors.rs
new file mode 100644
index 000000000000..a43162c1460a
--- /dev/null
+++ b/tvix/derivation/src/errors.rs
@@ -0,0 +1,44 @@
+use thiserror::Error;
+use tvix_store::store_path::ParseStorePathError;
+
+/// Errors that can occur during the validation of Derivation structs.
+#[derive(Debug, Error)]
+pub enum ValidateDerivationError {
+    // 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 parse path of output {0}: {1}.")]
+    InvalidOutputPath(String, ParseStorePathError),
+
+    // 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),
+}