mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-25 00:05:46 +00:00
Migrate custom error trait impls to thiserror (#1856)
* Migrate to thiserror * missing bits * review comment * Apply suggestions from code review Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com> * From<scale_decode::visitor::Error> to remove Into::intos * scale crates for core::error::Error * bump msrv 1.81 * make signer crate compile --------- Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com> Co-authored-by: James Wilson <james.wilson@parity.io>
This commit is contained in:
@@ -2,13 +2,13 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use core::fmt::Display;
|
||||
|
||||
use super::DeriveJunction;
|
||||
use alloc::{string::ToString, vec::Vec};
|
||||
use regex::Regex;
|
||||
use secrecy::SecretString;
|
||||
|
||||
use thiserror::Error as DeriveError;
|
||||
|
||||
// This code is taken from sp_core::crypto::DeriveJunction. The logic should be identical,
|
||||
// though the code is tweaked a touch!
|
||||
|
||||
@@ -116,23 +116,13 @@ impl core::str::FromStr for SecretUri {
|
||||
}
|
||||
|
||||
/// This is returned if `FromStr` cannot parse a string into a `SecretUri`.
|
||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||
#[derive(Debug, Copy, Clone, PartialEq, DeriveError)]
|
||||
pub enum SecretUriError {
|
||||
/// Parsing the secret URI from a string failed; wrong format.
|
||||
#[error("Invalid secret phrase format")]
|
||||
InvalidFormat,
|
||||
}
|
||||
|
||||
impl Display for SecretUriError {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
match self {
|
||||
SecretUriError::InvalidFormat => write!(f, "Invalid secret phrase format"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl std::error::Error for SecretUriError {}
|
||||
|
||||
once_static_cloned! {
|
||||
/// Interpret a phrase like:
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user