Skip to main content

systemprompt_models/profile/providers/
error.rs

1//! Failure modes of
2//! [`ProviderRegistry::validate`](super::ProviderRegistry::validate): duplicate
3//! provider names, empty or SSRF-blocked endpoints, and duplicate or
4//! empty model ids/aliases. Connectivity is the registry's authority, so these
5//! are the only errors emitted while checking it.
6
7use thiserror::Error;
8
9#[derive(Debug, Error)]
10pub enum ProviderRegistryError {
11    #[error("provider registry declares provider name '{name}' more than once")]
12    DuplicateProvider { name: String },
13
14    #[error("provider registry entry '{name}' has an empty endpoint")]
15    EmptyEndpoint { name: String },
16
17    #[error(
18        "provider registry entry '{provider}' endpoint '{endpoint}' is not permitted: {reason}"
19    )]
20    BlockedEndpoint {
21        provider: String,
22        endpoint: String,
23        reason: String,
24    },
25
26    #[error("provider registry model id or alias '{id}' is declared more than once")]
27    DuplicateModel { id: String },
28
29    #[error("provider registry model '{id}' has an empty id")]
30    EmptyModelId { id: String },
31
32    #[error("embedded default provider catalog failed to parse: {0}")]
33    InvalidDefaultCatalog(String),
34}
35
36pub type ProviderRegistryResult<T> = Result<T, ProviderRegistryError>;