Skip to main content

forest/key_management/
errors.rs

1// Copyright 2019-2026 ChainSafe Systems
2// SPDX-License-Identifier: Apache-2.0, MIT
3
4use std::io;
5
6use thiserror::Error;
7
8#[derive(Debug, Error)]
9pub enum Error {
10    /// info that corresponds to key does not exist
11    #[error("Key info not found")]
12    KeyInfo,
13    /// Key already exists in key store
14    #[error("Key already exists")]
15    KeyExists,
16    #[error("Key does not exist")]
17    KeyNotExists,
18    #[error("Key not found")]
19    NoKey,
20    #[error(transparent)]
21    Bls(#[from] bls_signatures::Error),
22    #[error(transparent)]
23    K256(#[from] k256::ecdsa::Error),
24    #[error(transparent)]
25    IO(#[from] io::Error),
26    #[error("{0}")]
27    Other(String),
28    #[error("Could not convert from KeyInfo to Key")]
29    KeyInfoConversion,
30}
31
32impl From<anyhow::Error> for Error {
33    fn from(value: anyhow::Error) -> Self {
34        Error::Other(value.to_string())
35    }
36}