Skip to content
Permalink
Browse files

Impl Display for account ledger error and remove unused variant

  • Loading branch information...
CodeSandwich committed May 14, 2019
1 parent 7ccceed commit e4fa5a1982265dddaa1814fa58480d673de8699d
Showing with 16 additions and 1 deletion.
  1. +16 −1 chain-impl-mockchain/src/account.rs
@@ -3,6 +3,7 @@ use crate::value::*;
use chain_crypto::{Ed25519Extended, PublicKey};
use imhamt::{Hamt, InsertError, UpdateError};
use std::collections::hash_map::DefaultHasher;
use std::fmt::{self, Display, Formatter};

pub type AccountAlg = Ed25519Extended;

@@ -11,12 +12,26 @@ pub type AccountAlg = Ed25519Extended;
pub enum LedgerError {
NonExistent,
AlreadyExists,
MismatchCounter,
NeedTotalWithdrawal,
NonZero,
ValueError(ValueError),
}

impl Display for LedgerError {
fn fmt(&self, formatter: &mut Formatter) -> Result<(), fmt::Error> {
match self {
LedgerError::NonExistent => "Account does not exist",
LedgerError::AlreadyExists => "Account already exists",
LedgerError::NeedTotalWithdrawal => {
"Operation counter reached its maximum and next operation must be full withdrawal"
}
LedgerError::NonZero => "Removed account is not empty",
LedgerError::ValueError(_) => "Value calculation failed",
}
.fmt(formatter)
}
}

impl From<ValueError> for LedgerError {
fn from(e: ValueError) -> Self {
LedgerError::ValueError(e)

0 comments on commit e4fa5a1

Please sign in to comment.
You can’t perform that action at this time.