mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 17:31:05 +00:00
use thiserror instead of derive_more for error handling (#10696)
* use thiserror instead of derive_more for error handling Signed-off-by: koushiro <koushiro.cqx@gmail.com> * Update utils/prometheus/src/lib.rs * Update utils/prometheus/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
async-trait = "0.1.50"
|
||||
derive_more = "0.99.16"
|
||||
thiserror = "1.0"
|
||||
sp-application-crypto = { version = "4.0.0", path = "../../primitives/application-crypto" }
|
||||
sp-core = { version = "4.1.0-dev", path = "../../primitives/core" }
|
||||
sp-keystore = { version = "0.10.0", path = "../../primitives/keystore" }
|
||||
|
||||
@@ -28,29 +28,31 @@ mod local;
|
||||
pub use local::LocalKeystore;
|
||||
|
||||
/// Keystore error.
|
||||
#[derive(Debug, derive_more::Display, derive_more::From)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum Error {
|
||||
/// IO error.
|
||||
Io(io::Error),
|
||||
#[error(transparent)]
|
||||
Io(#[from] io::Error),
|
||||
/// JSON error.
|
||||
Json(serde_json::Error),
|
||||
#[error(transparent)]
|
||||
Json(#[from] serde_json::Error),
|
||||
/// Invalid password.
|
||||
#[display(
|
||||
fmt = "Requested public key and public key of the loaded private key do not match. \n
|
||||
#[error(
|
||||
"Requested public key and public key of the loaded private key do not match. \n
|
||||
This means either that the keystore password is incorrect or that the private key was stored under a wrong public key."
|
||||
)]
|
||||
PublicKeyMismatch,
|
||||
/// Invalid BIP39 phrase
|
||||
#[display(fmt = "Invalid recovery phrase (BIP39) data")]
|
||||
#[error("Invalid recovery phrase (BIP39) data")]
|
||||
InvalidPhrase,
|
||||
/// Invalid seed
|
||||
#[display(fmt = "Invalid seed")]
|
||||
#[error("Invalid seed")]
|
||||
InvalidSeed,
|
||||
/// Public key type is not supported
|
||||
#[display(fmt = "Key crypto type is not supported")]
|
||||
#[error("Key crypto type is not supported")]
|
||||
KeyNotSupported(KeyTypeId),
|
||||
/// Keystore unavailable
|
||||
#[display(fmt = "Keystore unavailable")]
|
||||
#[error("Keystore unavailable")]
|
||||
Unavailable,
|
||||
}
|
||||
|
||||
@@ -69,13 +71,3 @@ impl From<Error> for TraitError {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::error::Error for Error {
|
||||
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
|
||||
match self {
|
||||
Error::Io(ref err) => Some(err),
|
||||
Error::Json(ref err) => Some(err),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user