Skip to main content

xmtp_db/encrypted_store/group_intent/
error.rs

1use thiserror::Error;
2use xmtp_common::{ErrorCode, RetryableError};
3use xmtp_proto::types::{Cursor, GroupId};
4
5use crate::group_intent::PayloadHash;
6
7#[derive(Debug, Error, ErrorCode)]
8#[error_code(internal)]
9pub enum GroupIntentError {
10    /// More than one dependency.
11    ///
12    /// Intent has multiple dependencies in same epoch. Retryable.
13    #[error(
14        "intent {} for group {group_id} has invalid dependencies={:?}. one message cannot have more than 1 dependency in same epoch",
15        hex::encode(payload_hash),
16        cursors
17    )]
18    MoreThanOneDependency {
19        payload_hash: PayloadHash,
20        cursors: Vec<Cursor>,
21        group_id: GroupId,
22    },
23    /// No dependency found.
24    ///
25    /// Intent has no known dependencies. Retryable.
26    #[error("intent with hash {hash} has no known dependencies")]
27    NoDependencyFound { hash: PayloadHash },
28}
29
30impl RetryableError for GroupIntentError {
31    fn is_retryable(&self) -> bool {
32        match self {
33            Self::MoreThanOneDependency { .. } => true,
34            Self::NoDependencyFound { .. } => true,
35        }
36    }
37}