Просмотр исходного кода

add Base58EncodeError and Base58DecodeError to error.rs

ghassmo 5 лет назад
Родитель
Сommit
e52ff2dfce
1 измененных файлов с 16 добавлено и 0 удалено
  1. 16 0
      src/error.rs

+ 16 - 0
src/error.rs

@@ -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())
+    }
+}