1use sc_keystore;
22use sp_blockchain;
23use sp_consensus;
24
25pub type Result<T> = std::result::Result<T, Error>;
27
28#[derive(Debug, thiserror::Error)]
30#[allow(missing_docs)]
31#[non_exhaustive]
32pub enum Error {
33 #[error(transparent)]
34 Client(#[from] sp_blockchain::Error),
35
36 #[error(transparent)]
37 Io(#[from] std::io::Error),
38
39 #[error(transparent)]
40 Consensus(#[from] sp_consensus::Error),
41
42 #[error(transparent)]
43 Network(#[from] sc_network::error::Error),
44
45 #[error(transparent)]
46 Keystore(#[from] sc_keystore::Error),
47
48 #[error(transparent)]
49 Telemetry(#[from] sc_telemetry::Error),
50
51 #[error("Best chain selection strategy (SelectChain) is not provided.")]
52 SelectChainRequired,
53
54 #[error("Tasks executor hasn't been provided.")]
55 TaskExecutorRequired,
56
57 #[error("Prometheus metrics error: {0}")]
58 Prometheus(#[from] prometheus_endpoint::PrometheusError),
59
60 #[error("Application: {0}")]
61 Application(#[from] Box<dyn std::error::Error + Send + Sync + 'static>),
62
63 #[error("Other: {0}")]
64 Other(String),
65}
66
67impl<'a> From<&'a str> for Error {
68 fn from(s: &'a str) -> Self {
69 Error::Other(s.into())
70 }
71}
72
73impl From<String> for Error {
74 fn from(s: String) -> Self {
75 Error::Other(s)
76 }
77}