use std::error::Error;
use std::fmt::{Display, Formatter, Result as FResult};
use std::path::PathBuf;
#[derive(Debug)]
pub enum CompileError {
InputOpenError { path: PathBuf, err: std::io::Error },
InputReadError { name: String, err: std::io::Error },
RemotePackageIndexError { endpoint: String, err: brane_tsk::api::Error },
RemoteDataIndexError { endpoint: String, err: brane_tsk::api::Error },
LocalPackageIndexError { err: brane_tsk::local::Error },
LocalDataIndexError { err: brane_tsk::local::Error },
WorkflowSerializeError { err: serde_json::Error },
OutputCreateError { path: PathBuf, err: std::io::Error },
OutputWriteError { name: String, err: std::io::Error },
CompileError { errs: Vec<brane_ast::Error> },
}
impl Display for CompileError {
fn fmt(&self, f: &mut Formatter<'_>) -> FResult {
use self::CompileError::*;
match self {
InputOpenError { path, err } => write!(f, "Failed to open input file '{}': {}", path.display(), err),
InputReadError { name, err } => write!(f, "Failed to read from input '{name}': {err}"),
RemotePackageIndexError { endpoint, err } => write!(f, "Failed to fetch remote package index from '{endpoint}': {err}"),
RemoteDataIndexError { endpoint, err } => write!(f, "Failed to fetch remote data index from '{endpoint}': {err}"),
LocalPackageIndexError { err } => write!(f, "Failed to fetch local package index: {err}"),
LocalDataIndexError { err } => write!(f, "Failed to fetch local data index: {err}"),
WorkflowSerializeError { err } => write!(f, "Failed to serialize the compiled workflow: {err}"),
OutputCreateError { path, err } => write!(f, "Failed to create output file '{}': {}", path.display(), err),
OutputWriteError { name, err } => write!(f, "Failed to write to output '{name}': {err}"),
CompileError { .. } => write!(f, "Failed to compile given workflow (see output above)"),
}
}
}
impl Error for CompileError {}
#[derive(Debug)]
pub struct IndexLocationParseError;
impl Display for IndexLocationParseError {
fn fmt(&self, f: &mut Formatter<'_>) -> FResult {
write!(f, "The impossible has happened; an IndexLocationParseError was raised, even though none exist")
}
}
impl Error for IndexLocationParseError {}