Skip to main content

exo_messaging/
error.rs

1// Copyright 2026 Exochain Foundation
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at:
6//
7//     https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// SPDX-License-Identifier: Apache-2.0
16
17//! Messaging-specific error types.
18
19/// Errors that can occur during messaging operations.
20#[derive(Debug, thiserror::Error)]
21pub enum MessagingError {
22    #[error("key exchange failed: {0}")]
23    KeyExchangeFailed(String),
24
25    #[error("encryption failed: {0}")]
26    EncryptionFailed(String),
27
28    #[error("decryption failed: ciphertext invalid or wrong key")]
29    DecryptionFailed,
30
31    #[error("signature verification failed")]
32    SignatureVerificationFailed,
33
34    #[error("death-trigger confirmation payload encoding failed: {0}")]
35    DeathConfirmationPayloadEncoding(String),
36
37    #[error("envelope signing payload encoding failed: {0}")]
38    EnvelopeSigningPayloadEncoding(String),
39
40    #[error("invalid envelope: {0}")]
41    InvalidEnvelope(String),
42
43    #[error("identity error: {0}")]
44    Identity(#[from] exo_identity::error::IdentityError),
45
46    #[error("death trigger already resolved")]
47    DeathTriggerAlreadyResolved,
48
49    #[error("invalid death verification: {0}")]
50    InvalidDeathVerification(String),
51
52    #[error("insufficient confirmations: need {need}, got {got}")]
53    InsufficientConfirmations { need: u8, got: u8 },
54
55    #[error("unauthorized death-trigger trustee: {0}")]
56    UnauthorizedTrustee(String),
57
58    #[error("duplicate confirmation from: {0}")]
59    DuplicateConfirmation(String),
60}