mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-09 21:21:11 +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:
@@ -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