refactor(tvix/derivation): use DerivationError in Output::validate

Change-Id: I7dbd3b8ff9ef92acddde2e579fb24b8311c34d8f
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7852
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
This commit is contained in:
Florian Klink 2023-01-17 12:04:15 +01:00 committed by flokli
parent eebb3ce028
commit 6e7f06d942
4 changed files with 18 additions and 12 deletions

View file

@ -1,5 +1,7 @@
use serde::{Deserialize, Serialize};
use tvix_store::store_path::{ParseStorePathError, StorePath};
use tvix_store::store_path::StorePath;
use crate::OutputError;
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
pub struct Output {
@ -22,9 +24,10 @@ impl Output {
self.hash.is_some()
}
pub fn validate(&self) -> Result<(), ParseStorePathError> {
pub fn validate(&self) -> Result<(), OutputError> {
// TODO: add validation for hash, hashAlgo
if let Err(e) = StorePath::from_absolute_path(&self.path) {
return Err(e);
return Err(OutputError::InvalidOutputPath(self.path.to_string(), e));
}
Ok(())
}