Skip to main content

systemprompt_provider_contracts/web_config/
error.rs

1//! Typed error returned by [`crate::web_config::WebConfig`] loading.
2//!
3//! Copyright (c) systemprompt.io — Business Source License 1.1.
4//! See <https://systemprompt.io> for licensing details.
5
6use std::path::PathBuf;
7
8use systemprompt_identifiers::LocaleCode;
9use thiserror::Error;
10
11#[derive(Debug, Error)]
12pub enum WebConfigError {
13    #[error("Failed to read web config at '{path}': {source}")]
14    Io {
15        path: PathBuf,
16        #[source]
17        source: std::io::Error,
18    },
19
20    #[error("Failed to parse web config: {0}")]
21    Parse(#[from] serde_yaml::Error),
22
23    #[error("Missing required field: {field}")]
24    MissingField { field: String },
25
26    #[error("Invalid value for {field}: {message}")]
27    InvalidValue { field: String, message: String },
28
29    #[error("{field} directory not found: {path}")]
30    PathNotFound { field: String, path: PathBuf },
31
32    #[error("default_locale '{default_locale}' is not in supported_locales")]
33    UnsupportedDefaultLocale { default_locale: LocaleCode },
34}