Skip to content

Commit

Permalink
add variant error
Browse files Browse the repository at this point in the history
  • Loading branch information
lemunozm committed May 7, 2024
1 parent 317990a commit 8c41d5d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pallets/loans/src/entities/loans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ impl<T: Config> ActiveLoan<T> {

ensure!(
self.total_repaid.effective()? >= expected_payment,
DispatchError::Other("payment overdue")
Error::<T>::from(BorrowLoanError::PaymentOverdue)
);

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion pallets/loans/src/tests/borrow_loan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ mod cashflow {
loan_id,
PrincipalInput::Internal(COLLATERAL_VALUE / 4)
),
DispatchError::Other("payment overdue")
Error::<Runtime>::from(BorrowLoanError::PaymentOverdue)
);
});
}
Expand Down
2 changes: 2 additions & 0 deletions pallets/loans/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8c41d5d

Please sign in to comment.