1use std::fmt;
2
3#[derive(Debug)]
4#[allow(dead_code)] pub enum KrustError {
6 IdentifierNotFound(String),
7 InvalidSeed(String),
8 SignatureVerificationFailed,
9 KelParseError(String),
10 IoError(std::io::Error),
11 KeriError(String),
12}
13
14impl fmt::Display for KrustError {
15 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
16 match self {
17 KrustError::IdentifierNotFound(alias) => {
18 write!(f, "Identifier '{}' not found", alias)
19 }
20 KrustError::InvalidSeed(msg) => {
21 write!(f, "Invalid seed: {}", msg)
22 }
23 KrustError::SignatureVerificationFailed => {
24 write!(f, "Signature verification failed")
25 }
26 KrustError::KelParseError(msg) => {
27 write!(f, "Failed to parse KEL: {}", msg)
28 }
29 KrustError::IoError(e) => {
30 write!(f, "IO error: {}", e)
31 }
32 KrustError::KeriError(msg) => {
33 write!(f, "KERI error: {}", msg)
34 }
35 }
36 }
37}
38
39impl std::error::Error for KrustError {}
40
41impl From<std::io::Error> for KrustError {
42 fn from(err: std::io::Error) -> Self {
43 KrustError::IoError(err)
44 }
45}