1// This file is part of Substrate.
23// Copyright (C) Parity Technologies (UK) Ltd.
4// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
56// This program is free software: you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation, either version 3 of the License, or
9// (at your option) any later version.
1011// This program is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
1516// You should have received a copy of the GNU General Public License
17// along with this program. If not, see <https://www.gnu.org/licenses/>.
1819//! Errors that can occur during the service operation.
2021use sc_keystore;
22use sp_blockchain;
23use sp_consensus;
2425/// Service Result typedef.
26pub type Result<T> = std::result::Result<T, Error>;
2728/// Service errors.
29#[derive(Debug, thiserror::Error)]
30#[allow(missing_docs)]
31#[non_exhaustive]
32pub enum Error {
33#[error(transparent)]
34Client(#[from] sp_blockchain::Error),
3536#[error(transparent)]
37Io(#[from] std::io::Error),
3839#[error(transparent)]
40Consensus(#[from] sp_consensus::Error),
4142#[error(transparent)]
43Network(#[from] sc_network::error::Error),
4445#[error(transparent)]
46Keystore(#[from] sc_keystore::Error),
4748#[error(transparent)]
49Telemetry(#[from] sc_telemetry::Error),
5051#[error("Best chain selection strategy (SelectChain) is not provided.")]
52SelectChainRequired,
5354#[error("Tasks executor hasn't been provided.")]
55TaskExecutorRequired,
5657#[error("Prometheus metrics error: {0}")]
58Prometheus(#[from] prometheus_endpoint::PrometheusError),
5960#[error("Application: {0}")]
61Application(#[from] Box<dyn std::error::Error + Send + Sync + 'static>),
6263#[error("Other: {0}")]
64Other(String),
65}
6667impl<'a> From<&'a str> for Error {
68fn from(s: &'a str) -> Self {
69 Error::Other(s.into())
70 }
71}
7273impl From<String> for Error {
74fn from(s: String) -> Self {
75 Error::Other(s)
76 }
77}