diff --git a/subcryptor/src/error.rs b/subcryptor/src/error.rs index 7aa25b6..6134a4c 100644 --- a/subcryptor/src/error.rs +++ b/subcryptor/src/error.rs @@ -7,23 +7,23 @@ use thiserror::Error as ThisError; #[allow(missing_docs)] #[derive(Debug, ThisError)] pub enum Error { - #[error("{0:?}")] + #[error("[subcryptor] {0:?}")] ArrayBytes(array_bytes::Error), #[error(transparent)] Base64Decode(#[from] base64::DecodeError), #[error(transparent)] CryptoSecretBox(#[from] CryptoSecretBox), - #[error("{0:?}")] + #[error("[subcryptor] from base58 error, {0:?}")] FromBase58(base58::FromBase58Error), - #[error("invalid prefix, {0:?}")] + #[error("[subcryptor] invalid prefix, {0:?}")] InvalidPrefix(u8), - #[error("invalid ss58 address, {0:?}")] + #[error("[subcryptor] invalid ss58 address, {0:?}")] InvalidSs58Address(String), #[error(transparent)] Scrypt(#[from] scrypt::errors::InvalidOutputLen), - #[error("unsupported encryption type")] + #[error("[subcryptor] unsupported encryption type")] UnsupportedEncryptionType, - #[error("unsupported network, {0:?}")] + #[error("[subcryptor] unsupported network, {0:?}")] UnsupportedNetwork(String), } @@ -31,8 +31,8 @@ pub enum Error { #[allow(missing_docs)] #[derive(Debug, ThisError)] pub enum CryptoSecretBox { - #[error("{0:?}")] + #[error("[subcryptor] crypto secretbox general error, {0:?}")] General(crypto_secretbox::Error), - #[error("{0:?}")] + #[error("[subcryptor] crypto secretbox cipher error, {0:?}")] Cipher(crypto_secretbox::cipher::InvalidLength), } diff --git a/subcryptor/src/test.rs b/subcryptor/src/test.rs index 36e0532..7511815 100644 --- a/subcryptor/src/test.rs +++ b/subcryptor/src/test.rs @@ -17,7 +17,7 @@ fn ss58_address_of_should_work() { fn ss58_address_of_should_fail() { assert_eq!( ss58_address_of(&[], "invalid network").unwrap_err().to_string(), - "unsupported network, \"invalid network\"" + "[subcryptor] unsupported network, \"invalid network\"" ); } @@ -31,21 +31,24 @@ fn public_key_of_should_work() { #[test] fn public_key_of_should_fail() { - assert_eq!(public_key_of::("").unwrap_err().to_string(), "invalid ss58 address, \"\""); + assert_eq!( + public_key_of::("").unwrap_err().to_string(), + "[subcryptor] invalid ss58 address, \"\"" + ); assert_eq!( public_key_of::("?56HGo9setPcU2qhFMVWLkcmtCEGySLwNqa3DaEiYSWtte4Y") .unwrap_err() .to_string(), - "InvalidBase58Character('?', 0)" + "[subcryptor] from base58 error, InvalidBase58Character('?', 0)" ); assert_eq!( public_key_of::("56HGo9setPcU2qhFMVWLkcmtCEGySLwNqa3DaEiYSWtte4Y") .unwrap_err() .to_string(), - "invalid prefix, 180" + "[subcryptor] invalid prefix, 180" ); assert_eq!( public_key_of::("15").unwrap_err().to_string(), - "invalid ss58 address, \"15\"" + "[subcryptor] invalid ss58 address, \"15\"" ); }