Skip to main content

ant_types/
error.rs

1use thiserror::Error;
2
3/// Errors raised by the core domain layer.
4///
5/// Consumers may map these to HTTP statuses.
6#[derive(Debug, Error)]
7pub enum CoreError {
8    #[error("invalid config: missing required field `{field}`")]
9    MissingConfigField { field: String },
10
11    #[error("invalid config: field `{field}` has wrong type")]
12    WrongConfigType { field: String },
13
14    #[error("project not found: id={0:?}")]
15    ProjectNotFound(crate::ProjectId),
16
17    #[error("project namespace already exists: {0}")]
18    NamespaceConflict(String),
19
20    #[error("invalid input: {0}")]
21    InvalidInput(String),
22
23    /// Append-only resource (typically Observation) was re-submitted with
24    /// the same id but different content. Mapped to HTTP 409.
25    #[error("conflict: {0}")]
26    Conflict(String),
27
28    /// No (or invalid) authentication credentials were presented.
29    /// Mapped to HTTP 401 Unauthorized.
30    #[error("unauthorized: {0}")]
31    Unauthorized(String),
32
33    /// Caller is authenticated but lacks the required scope or
34    /// tenant binding for the action. Mapped to HTTP 403 Forbidden.
35    #[error("forbidden: {0}")]
36    Forbidden(String),
37}