Skip to main content

core_identity/
error.rs

1use alloc::string::String;
2use core::fmt;
3
4/// Specific errors for cryptographic identity operations
5#[derive(Debug)]
6pub enum IdentityError {
7    #[allow(dead_code)]
8    Generation(String),
9
10    InvalidSignature,
11
12    InvalidPublicKey,
13
14    #[allow(dead_code)]
15    InvalidKey(String),
16
17    InvalidState(String),
18}
19
20impl fmt::Display for IdentityError {
21    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
22        match self {
23            Self::Generation(msg) => write!(f, "Error generating identity: {msg}"),
24            Self::InvalidSignature => write!(f, "Invalid signature"),
25            Self::InvalidPublicKey => write!(f, "Invalid public key"),
26            Self::InvalidKey(msg) => write!(f, "Invalid key: {msg}"),
27            Self::InvalidState(msg) => write!(f, "Invalid state: {msg}"),
28        }
29    }
30}
31
32impl core::error::Error for IdentityError {}
33
34/// Specific Result type for identity operations
35pub type Result<T> = core::result::Result<T, IdentityError>;