mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 01:47:55 +00:00
f1926f55cf
* Replace substrate crate aliases with actual crate names * Alias parity-scale-codec to just codec, like in substrate * Format code
84 lines
2.3 KiB
Rust
84 lines
2.3 KiB
Rust
// Copyright 2019 Parity Technologies (UK) Ltd.
|
|
// This file is part of substrate-subxt.
|
|
//
|
|
// subxt is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// subxt is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with substrate-subxt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
use jsonrpc_core_client::RpcError;
|
|
use sp_core::crypto::SecretStringError;
|
|
use sp_runtime::transaction_validity::TransactionValidityError;
|
|
|
|
use crate::{
|
|
events::EventsError,
|
|
metadata::MetadataError,
|
|
};
|
|
|
|
/// Error enum.
|
|
#[derive(Debug, thiserror::Error)]
|
|
pub enum Error {
|
|
/// Io error.
|
|
#[error("Io error: {0}")]
|
|
Io(#[from] std::io::Error),
|
|
/// Codec error.
|
|
#[error("Scale codec error: {0}")]
|
|
Codec(#[from] codec::Error),
|
|
/// Rpc error.
|
|
#[error("Rpc error: {0}")]
|
|
Rpc(RpcError),
|
|
/// Secret string error.
|
|
#[error("Secret String Error")]
|
|
SecretString(SecretStringError),
|
|
/// Extrinsic validity error
|
|
#[error("Transaction Validity Error: {0:?}")]
|
|
Invalid(TransactionValidityError),
|
|
/// Events error.
|
|
#[error("Event error: {0}")]
|
|
Events(#[from] EventsError),
|
|
/// Metadata error.
|
|
#[error("Metadata error: {0}")]
|
|
Metadata(#[from] MetadataError),
|
|
/// Other error.
|
|
#[error("Other error: {0}")]
|
|
Other(String),
|
|
}
|
|
|
|
impl From<RpcError> for Error {
|
|
fn from(error: RpcError) -> Self {
|
|
Error::Rpc(error)
|
|
}
|
|
}
|
|
|
|
impl From<SecretStringError> for Error {
|
|
fn from(error: SecretStringError) -> Self {
|
|
Error::SecretString(error)
|
|
}
|
|
}
|
|
|
|
impl From<TransactionValidityError> for Error {
|
|
fn from(error: TransactionValidityError) -> Self {
|
|
Error::Invalid(error)
|
|
}
|
|
}
|
|
|
|
impl From<&str> for Error {
|
|
fn from(error: &str) -> Self {
|
|
Error::Other(error.into())
|
|
}
|
|
}
|
|
|
|
impl From<String> for Error {
|
|
fn from(error: String) -> Self {
|
|
Error::Other(error)
|
|
}
|
|
}
|