systemprompt_models/errors/
validation.rs1#[derive(Debug, Clone, thiserror::Error)]
5pub enum ConfigValidationError {
6 #[error("{0}")]
7 Required(String),
8
9 #[error("{0}")]
10 InvalidField(String),
11
12 #[error("{0}")]
13 PortConflict(String),
14
15 #[error("{0}")]
16 UnknownReference(String),
17
18 #[error("{0}")]
19 CircularDependency(String),
20
21 #[error("{0}")]
22 BusinessRule(String),
23
24 #[error(
25 "Profile is missing required `system_admin.username`. Set it explicitly or supply the \
26 `SYSTEMPROMPT_SYSTEM_ADMIN` environment variable."
27 )]
28 MissingSystemAdmin,
29}
30
31impl ConfigValidationError {
32 #[must_use]
33 pub fn required(msg: impl Into<String>) -> Self {
34 Self::Required(msg.into())
35 }
36
37 #[must_use]
38 pub fn invalid_field(msg: impl Into<String>) -> Self {
39 Self::InvalidField(msg.into())
40 }
41
42 #[must_use]
43 pub fn port_conflict(msg: impl Into<String>) -> Self {
44 Self::PortConflict(msg.into())
45 }
46
47 #[must_use]
48 pub fn unknown_reference(msg: impl Into<String>) -> Self {
49 Self::UnknownReference(msg.into())
50 }
51
52 #[must_use]
53 pub fn circular_dependency(msg: impl Into<String>) -> Self {
54 Self::CircularDependency(msg.into())
55 }
56
57 #[must_use]
58 pub fn business_rule(msg: impl Into<String>) -> Self {
59 Self::BusinessRule(msg.into())
60 }
61}