Skip to main content

platform/realm/
error.rs

1//! Realm 错误类型定义
2//!
3//! 定义了 Realm 管理相关的错误类型
4
5use thiserror::Error;
6
7#[derive(Debug, Error)]
8pub enum RealmError {
9    #[error("Database error: {0}")]
10    DatabaseError(String),
11
12    #[error("Validation error: {0}")]
13    ValidationError(String),
14
15    #[error("Realm not found")]
16    NotFound,
17
18    #[error("Realm already exists")]
19    AlreadyExists,
20
21    #[error("Key expired")]
22    KeyExpired,
23
24    #[error("Key does not exist")]
25    KeyNotExist,
26
27    #[error("Parse error: {0}")]
28    ParseError(String),
29}
30
31impl From<sqlx::Error> for RealmError {
32    fn from(err: sqlx::Error) -> Self {
33        RealmError::DatabaseError(err.to_string())
34    }
35}