Skip to content

Commit

Permalink
VectorToArrayConversionError
Browse files Browse the repository at this point in the history
  • Loading branch information
bodrych committed Dec 11, 2023
1 parent 5abb9db commit 87cea8b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ pub enum Error {
HexError(#[from] FromHexError),
#[error("unsupported operation: {0}")]
UnsupportedOperation(String),
#[error("failed to convert vector to array")]
PrivateKeyConversionError,
#[error("failed to convert vector {0:?} to array")]
VectorToArrayConversionError(Vec<u8>),
#[error("alias must be {min_length:?} to {max_length:?} length of {alphabet:?} and may have a prefix \"{max_length:?}{chain_id:?}:\"")]
InvalidAliasName {
min_length: u8,
Expand Down
5 changes: 1 addition & 4 deletions src/model/account/private_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ impl std::str::FromStr for PrivateKey {

fn from_str(base58string: &str) -> Result<PrivateKey> {
let bytes = Base58::decode(base58string)?;
let bytes_array: [u8; 32] = match bytes.try_into() {
Ok(v) => v,
Err(_) => return Err(Error::PrivateKeyConversionError),
};
let bytes_array: [u8; 32] = bytes.try_into().map_err(|e| Error::VectorToArrayConversionError(e))?;
PrivateKey::from_bytes(bytes_array)
}
}
Expand Down

0 comments on commit 87cea8b

Please sign in to comment.