use capsula_core::error::CapsulaError;
use std::path::PathBuf;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum FileHookError {
#[error("File not found: {path}")]
FileNotFound { path: PathBuf },
#[error("No files matched the pattern: {pattern}")]
NoFilesMatched { pattern: String },
#[error(transparent)]
InvalidPattern(#[from] globwalk::GlobError),
#[error("Run directory is not set")]
RunDirNotSet,
#[error("Invalid run directory: {path}")]
InvalidRunDir { path: PathBuf },
#[error("Failed to read file {path}: {source}")]
ReadError {
path: PathBuf,
#[source]
source: std::io::Error,
},
#[error("Failed to compute hash for {path}: {message}")]
HashError { path: PathBuf, message: String },
#[error("Failed to serialize file hook: {0}")]
Serialization(#[from] serde_json::Error),
#[error(transparent)]
Io(#[from] std::io::Error),
}
impl From<FileHookError> for CapsulaError {
fn from(err: FileHookError) -> Self {
CapsulaError::HookFailed {
hook: "capture-file".to_string(),
message: err.to_string(),
source: Box::new(err),
}
}
}