Skip to main content

systemprompt_models/errors/
parse.rs

1//! Parsing-layer error types: enum tag dispatch and config bootstrap.
2//!
3//! Copyright (c) systemprompt.io — Business Source License 1.1.
4//! See <https://systemprompt.io> for licensing details.
5
6#[derive(Debug, Clone, thiserror::Error, PartialEq, Eq)]
7#[error("invalid {kind}: {value}")]
8pub struct ParseEnumError {
9    pub kind: &'static str,
10    pub value: String,
11}
12
13impl ParseEnumError {
14    #[must_use]
15    pub fn new(kind: &'static str, value: impl Into<String>) -> Self {
16        Self {
17            kind,
18            value: value.into(),
19        }
20    }
21}
22
23#[derive(Debug, Clone, Copy, thiserror::Error)]
24pub enum ConfigError {
25    #[error("Config not initialized. Call Config::init() first.")]
26    NotInitialized,
27
28    #[error("DATABASE_URL must be a PostgreSQL connection string (postgres:// or postgresql://)")]
29    InvalidPostgresUrl,
30}