Skip to main content

nexus/routing/
error.rs

1//! Error types for routing failures
2
3use crate::routing::reconciler::intent::RejectionReason;
4use thiserror::Error;
5
6/// Errors that can occur during backend selection
7#[derive(Debug, Error)]
8pub enum RoutingError {
9    /// The requested model was not found in any backend
10    #[error("Model '{model}' not found")]
11    ModelNotFound { model: String },
12
13    /// No healthy backend is available for the requested model
14    #[error("No healthy backend available for model '{model}'")]
15    NoHealthyBackend { model: String },
16
17    /// No backend supports the required capabilities
18    #[error("No backend supports required capabilities for model '{model}': {missing:?}")]
19    CapabilityMismatch { model: String, missing: Vec<String> },
20
21    /// All models in the fallback chain were exhausted
22    #[error("All backends in fallback chain unavailable: {chain:?}")]
23    FallbackChainExhausted { chain: Vec<String> },
24
25    /// Request rejected with detailed reasons from reconcilers (FR-004)
26    #[error("Request rejected by reconciliation pipeline")]
27    Reject {
28        rejection_reasons: Vec<RejectionReason>,
29    },
30
31    /// Request should be queued (all backends at capacity, queue enabled)
32    #[error("All backends at capacity, request queued")]
33    Queue {
34        reason: String,
35        estimated_wait_ms: u64,
36    },
37}