1use thiserror::Error;
4
5pub type Result<T> = std::result::Result<T, PhotonError>;
7
8#[derive(Debug, Clone, Error)]
10pub enum PhotonError {
11 #[error("topic not found: {0}")]
13 TopicNotFound(String),
14
15 #[error("subscription not found: {0}")]
17 SubscriptionNotFound(String),
18
19 #[error("event not found: {0}")]
21 EventNotFound(String),
22
23 #[error("invalid topic name: {0}")]
25 InvalidTopicName(String),
26
27 #[error("payload error: {0}")]
29 PayloadError(String),
30
31 #[error("schema mismatch: {0}")]
33 SchemaMismatch(String),
34
35 #[error("topic already exists: {0}")]
37 TopicAlreadyExists(String),
38
39 #[error("subscription name required for durable subscriptions")]
41 SubscriptionNameRequired,
42
43 #[error("persistence error: {0}")]
45 PersistenceError(String),
46
47 #[error("identity error: {0}")]
53 Identity(String),
54
55 #[error("internal error: {0}")]
57 Internal(String),
58}
59
60impl From<serde_json::Error> for PhotonError {
61 fn from(err: serde_json::Error) -> Self {
62 Self::PayloadError(err.to_string())
63 }
64}
65
66impl From<anyhow::Error> for PhotonError {
67 fn from(err: anyhow::Error) -> Self {
68 Self::Internal(err.to_string())
69 }
70}