add Base58EncodeError and Base58DecodeError to error.rs

This commit is contained in:
ghassmo
2021-08-10 02:34:47 +03:00
parent cf0501c330
commit e52ff2dfce

View File

@@ -50,6 +50,8 @@ pub enum Error {
TomlDeserializeError(String),
TomlSerializeError(String),
CashierNoReply,
Base58EncodeError(String),
Base58DecodeError(String),
}
impl std::error::Error for Error {}
@@ -97,6 +99,8 @@ impl fmt::Display for Error {
Error::EmptyPassword => f.write_str("Password is empty. Cannot create database"),
Error::TomlDeserializeError(ref err) => write!(f, "Toml parsing error: {}", err),
Error::TomlSerializeError(ref err) => write!(f, "Toml parsing error: {}", err),
Error::Base58EncodeError(ref err) => write!(f, "bs58 encode error: {}", err),
Error::Base58DecodeError(ref err) => write!(f, "bs58 decode error: {}", err),
Error::CashierNoReply => f.write_str("Cashier did not reply with BTC address"),
}
}
@@ -216,3 +220,15 @@ impl From<toml::ser::Error> for Error {
Error::TomlSerializeError(err.to_string())
}
}
impl From<bs58::encode::Error> for Error {
fn from(err: bs58::encode::Error) -> Error {
Error::Base58EncodeError(err.to_string())
}
}
impl From<bs58::decode::Error> for Error {
fn from(err: bs58::decode::Error) -> Error {
Error::Base58DecodeError(err.to_string())
}
}