Skip to main content

parsnip_core/
error.rs

1//! Error types for Parsnip Core
2
3use thiserror::Error;
4
5/// Result type alias using Parsnip's Error
6pub type Result<T> = std::result::Result<T, Error>;
7
8/// Parsnip error types
9#[derive(Error, Debug)]
10pub enum Error {
11    #[error("Entity not found: {0}")]
12    EntityNotFound(String),
13
14    #[error("Entity already exists: {0}")]
15    EntityExists(String),
16
17    #[error("Project not found: {0}")]
18    ProjectNotFound(String),
19
20    #[error("Project already exists: {0}")]
21    ProjectExists(String),
22
23    #[error("Relation not found: {from} -> {to}")]
24    RelationNotFound { from: String, to: String },
25
26    #[error("Invalid entity name: {0}")]
27    InvalidEntityName(String),
28
29    #[error("Invalid project name: {0}")]
30    InvalidProjectName(String),
31
32    #[error("Validation error: {0}")]
33    Validation(String),
34
35    #[error("Storage error: {0}")]
36    Storage(String),
37
38    #[error("Search error: {0}")]
39    Search(String),
40
41    #[error("Serialization error: {0}")]
42    Serialization(#[from] serde_json::Error),
43
44    #[error("Internal error: {0}")]
45    Internal(String),
46}