sc_transaction_pool/common/error.rs
1// This file is part of Substrate.
2
3// Copyright (C) Parity Technologies (UK) Ltd.
4// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
5
6// 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.
10
11// 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.
15
16// 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/>.
18
19//! Transaction pool error.
20
21use sc_transaction_pool_api::error::Error as TxPoolError;
22
23/// Transaction pool result.
24pub type Result<T> = std::result::Result<T, Error>;
25
26/// Transaction pool error type.
27#[derive(Debug, thiserror::Error)]
28#[allow(missing_docs)]
29pub enum Error {
30 #[error("Transaction pool error: {0}")]
31 Pool(#[from] TxPoolError),
32
33 #[error("Blockchain error: {0}")]
34 Blockchain(#[from] sp_blockchain::Error),
35
36 #[error("Block conversion error: {0}")]
37 BlockIdConversion(String),
38
39 #[error("Runtime error: {0}")]
40 RuntimeApi(String),
41}
42
43impl sc_transaction_pool_api::error::IntoPoolError for Error {
44 fn into_pool_error(self) -> std::result::Result<TxPoolError, Self> {
45 match self {
46 Error::Pool(e) => Ok(e),
47 e => Err(e),
48 }
49 }
50}