mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-09 20:11:09 +00:00
Remove uses of Error::description() use Display instead (#2887)
* Remove all uses of Error::description() - use Display instead
This commit is contained in:
@@ -190,7 +190,7 @@ pub fn block_id_to_lookup_key<Block>(
|
||||
/// Maps database error to client error
|
||||
pub fn db_err(err: io::Error) -> client::error::Error {
|
||||
use std::error::Error;
|
||||
client::error::Error::Backend(err.description().into())
|
||||
client::error::Error::Backend(format!("{}", err))
|
||||
}
|
||||
|
||||
/// Open RocksDB database.
|
||||
|
||||
@@ -33,7 +33,7 @@ pub enum Error {
|
||||
/// Transaction pool error,
|
||||
Pool(txpool::error::Error),
|
||||
/// Verification error
|
||||
#[display(fmt="Extrinsic verification error: {}", "_0.description()")]
|
||||
#[display(fmt="Extrinsic verification error: {}", _0)]
|
||||
Verification(Box<dyn std::error::Error + Send>),
|
||||
/// Incorrect extrinsic format.
|
||||
#[display(fmt="Invalid extrinsic format")]
|
||||
@@ -85,7 +85,7 @@ impl From<Error> for rpc::Error {
|
||||
},
|
||||
Error::Verification(e) => rpc::Error {
|
||||
code: rpc::ErrorCode::ServerError(VERIFICATION_ERROR),
|
||||
message: e.description().into(),
|
||||
message: format!("Verification Error: {}", e).into(),
|
||||
data: Some(format!("{:?}", e).into()),
|
||||
},
|
||||
Error::Pool(PoolError::InvalidTransaction(code)) => rpc::Error {
|
||||
|
||||
@@ -37,21 +37,17 @@ pub enum Error<E> {
|
||||
|
||||
impl<E: std::error::Error> fmt::Display for Error<E> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
use std::error::Error;
|
||||
write!(f, "{}", self.description())
|
||||
let message = match *self {
|
||||
Error::Duplicate => "Hash already exists in Tree".into(),
|
||||
Error::UnfinalizedAncestor => "Finalized descendent of Tree node without finalizing its ancestor(s) first".into(),
|
||||
Error::Revert => "Tried to import or finalize node that is an ancestor of a previously finalized node".into(),
|
||||
Error::Client(ref err) => format!("Client error: {}", err),
|
||||
};
|
||||
write!(f, "{}", message)
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: std::error::Error> std::error::Error for Error<E> {
|
||||
fn description(&self) -> &str {
|
||||
match *self {
|
||||
Error::Duplicate => "Hash already exists in Tree",
|
||||
Error::UnfinalizedAncestor => "Finalized descendent of Tree node without finalizing its ancestor(s) first",
|
||||
Error::Revert => "Tried to import or finalize node that is an ancestor of a previously finalized node",
|
||||
Error::Client(ref err) => err.description(),
|
||||
}
|
||||
}
|
||||
|
||||
fn cause(&self) -> Option<&dyn std::error::Error> {
|
||||
None
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user