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//!
7//! Copyright (c) systemprompt.io — Business Source License 1.1.
8//! See <https://systemprompt.io> for licensing details.
9
10use thiserror::Error;
11
12#[derive(Debug, Error)]
13pub enum ProviderRegistryError {
14    #[error("provider registry declares provider name '{name}' more than once")]
15    DuplicateProvider { name: String },
16
17    #[error("provider registry entry '{name}' has an empty endpoint")]
18    EmptyEndpoint { name: String },
19
20    #[error(
21        "provider registry entry '{provider}' endpoint '{endpoint}' is not permitted: {reason}"
22    )]
23    BlockedEndpoint {
24        provider: String,
25        endpoint: String,
26        reason: String,
27    },
28
29    #[error("provider registry model id or alias '{id}' is declared more than once")]
30    DuplicateModel { id: String },
31
32    #[error("provider registry model '{id}' has an empty id")]
33    EmptyModelId { id: String },
34
35    #[error("embedded default provider catalog failed to parse: {0}")]
36    InvalidDefaultCatalog(String),
37}
38
39pub type ProviderRegistryResult<T> = Result<T, ProviderRegistryError>;