1use thiserror::Error;
2
3#[derive(Debug, Error)]
5pub enum SignerError {
6 #[error("{0}")]
8 Msg(String),
9
10 #[error(transparent)]
12 Io(#[from] std::io::Error),
13
14 #[error(transparent)]
16 SerdeJson(#[from] serde_json::Error),
17
18 #[error(transparent)]
20 Base64(#[from] base64::DecodeError),
21
22 #[error("crypto error: {0}")]
24 Crypto(String),
25
26 #[error(transparent)]
28 Utf8(#[from] std::string::FromUtf8Error),
29
30 #[error("signature error: {0}")]
32 Signature(String),
33}
34
35pub type Result<T> = std::result::Result<T, SignerError>;
37
38impl From<chacha20poly1305::aead::Error> for SignerError {
39 fn from(err: chacha20poly1305::aead::Error) -> Self {
40 SignerError::Crypto(err.to_string())
41 }
42}
43
44impl From<schnorrkel::SignatureError> for SignerError {
45 fn from(err: schnorrkel::SignatureError) -> Self {
46 SignerError::Signature(err.to_string())
47 }
48}