Skip to main content

closure_tree/
error.rs

1use thiserror::Error;
2
3/// Errors returned by the closure-tree helper APIs.
4#[derive(Debug, Error)]
5pub enum ClosureTreeError {
6    #[error("closure-tree currently supports PostgreSQL connections only")]
7    UnsupportedBackend,
8
9    #[error("database error: {0}")]
10    Database(#[from] sea_orm::DbErr),
11
12    #[error("sqlx error: {0}")]
13    Sqlx(#[from] sqlx::Error),
14
15    #[error("path cannot be empty")]
16    EmptyPath,
17
18    #[error("closure-tree invariant violation: {0}")]
19    Invariant(String),
20}
21
22impl ClosureTreeError {
23    pub fn invariant(detail: impl Into<String>) -> Self {
24        Self::Invariant(detail.into())
25    }
26}