use thiserror::Error;
use crate::catalog::CatalogError;
use crate::spec::SpecError;
#[derive(Debug, Error)]
pub enum ProjectionError {
#[error("intent_index {requested} out of bounds (have {available} intents)")]
IntentIndexOutOfBounds { requested: usize, available: usize },
#[error("cannot project service with no intents")]
EmptyIntents,
#[error("projector referenced unknown component '{type_name}'")]
UnknownComponent { type_name: String },
#[error("catalog validation failed: {}", format_catalog_errors(.0))]
CatalogValidation(Vec<CatalogError>),
#[error("spec build failed: {0}")]
SpecBuild(#[from] SpecError),
}
fn format_catalog_errors(errors: &[CatalogError]) -> String {
errors
.iter()
.map(|e| e.to_string())
.collect::<Vec<_>>()
.join("; ")
}