From 8c41d5d20589deeb38404fa85f59d5231e07b59b Mon Sep 17 00:00:00 2001 From: lemunozm Date: Tue, 7 May 2024 15:20:47 +0200 Subject: [PATCH] add variant error --- pallets/loans/src/entities/loans.rs | 2 +- pallets/loans/src/tests/borrow_loan.rs | 2 +- pallets/loans/src/types/mod.rs | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pallets/loans/src/entities/loans.rs b/pallets/loans/src/entities/loans.rs index a0cc2322ca..2deabecc8a 100644 --- a/pallets/loans/src/entities/loans.rs +++ b/pallets/loans/src/entities/loans.rs @@ -370,7 +370,7 @@ impl ActiveLoan { ensure!( self.total_repaid.effective()? >= expected_payment, - DispatchError::Other("payment overdue") + Error::::from(BorrowLoanError::PaymentOverdue) ); Ok(()) diff --git a/pallets/loans/src/tests/borrow_loan.rs b/pallets/loans/src/tests/borrow_loan.rs index 90645656ee..fcaa8d7a16 100644 --- a/pallets/loans/src/tests/borrow_loan.rs +++ b/pallets/loans/src/tests/borrow_loan.rs @@ -734,7 +734,7 @@ mod cashflow { loan_id, PrincipalInput::Internal(COLLATERAL_VALUE / 4) ), - DispatchError::Other("payment overdue") + Error::::from(BorrowLoanError::PaymentOverdue) ); }); } diff --git a/pallets/loans/src/types/mod.rs b/pallets/loans/src/types/mod.rs index ee9def50ed..2d279fb9e9 100644 --- a/pallets/loans/src/types/mod.rs +++ b/pallets/loans/src/types/mod.rs @@ -44,6 +44,8 @@ pub enum BorrowLoanError { Restriction, /// Emits when maturity has passed and borrower tried to borrow more MaturityDatePassed, + /// Emits when the cashflow payment is overdue + PaymentOverdue, } /// Error related to loan borrowing