use crate::blueprint::ErrorHandler;
use crate::blueprint::conversions::coordinates2coordinates;
use pavex_bp_schema::{Blueprint as BlueprintSchema, Component, Location};
use super::reflection::AnnotationCoordinates;
pub struct Route {
#[doc(hidden)]
pub coordinates: AnnotationCoordinates,
}
pub struct RegisteredRoute<'a> {
pub(crate) blueprint: &'a mut BlueprintSchema,
pub(crate) component_id: usize,
}
impl RegisteredRoute<'_> {
#[track_caller]
pub fn error_handler(mut self, error_handler: ErrorHandler) -> Self {
let error_handler = pavex_bp_schema::ErrorHandler {
coordinates: coordinates2coordinates(error_handler.coordinates),
registered_at: Location::caller(),
};
self.route().error_handler = Some(error_handler);
self
}
fn route(&mut self) -> &mut pavex_bp_schema::Route {
let component = &mut self.blueprint.components[self.component_id];
let Component::Route(c) = component else {
unreachable!("The component should be a route")
};
c
}
}