Skip to main content

systemprompt_models/profile/gateway/
error.rs

1//! Failure modes emitted while validating the gateway's references into the
2//! provider registry: duplicate route ids, and a route or `default_provider`
3//! naming a provider absent from `profile.providers`.
4//!
5//! Copyright (c) systemprompt.io — Business Source License 1.1.
6//! See <https://systemprompt.io> for licensing details.
7
8use thiserror::Error;
9
10#[derive(Debug, Error)]
11pub enum GatewayProfileError {
12    #[error("gateway route id '{id}' is declared more than once")]
13    DuplicateRouteId { id: String },
14
15    #[error("gateway route '{route}' provider '{provider}' is not declared in profile.providers")]
16    RouteProviderNotInRegistry { route: String, provider: String },
17
18    #[error("gateway default_provider '{provider}' is not declared in profile.providers")]
19    DefaultProviderNotInRegistry { provider: String },
20
21    #[error("system_prompt override with action 'replace' must set a 'prompt'")]
22    OverrideReplaceMissingPrompt,
23
24    #[error("system_prompt override with action 'strip' must not set a 'prompt'")]
25    OverrideStripWithPrompt,
26
27    #[error("system_prompt override provider '{provider}' is not declared in profile.providers")]
28    OverrideProviderNotInRegistry { provider: String },
29
30    #[error("route `when.min_tools` must be at least 1 (0 matches every request)")]
31    RouteMatchZeroMinTools,
32
33    #[error("route `when` sets `requires_tools: false` but also a positive `min_tools`")]
34    RouteMatchContradictoryTools,
35}
36
37pub type GatewayResult<T> = Result<T, GatewayProfileError>;