Skip to content

feat(loan_manager): add repayment below minimum error handling and up…#37

Merged
ogazboiz merged 1 commit into
LabsCrypt:mainfrom
BigJohn-dev:LoanManager-uses-raw-panics-for-user-facing-failures-instead-of-typed-LoanError-returns
Jun 20, 2026
Merged

feat(loan_manager): add repayment below minimum error handling and up…#37
ogazboiz merged 1 commit into
LabsCrypt:mainfrom
BigJohn-dev:LoanManager-uses-raw-panics-for-user-facing-failures-instead-of-typed-LoanError-returns

Conversation

@BigJohn-dev

Copy link
Copy Markdown
Contributor

Closes #8

✅ Requested error handling updates are in place

I updated the contracts so the user-facing cases now return typed errors instead of panicking:

  • In lib.rs, repay now returns LoanError::RepaymentBelowMinimum for partial repayments that fall below the configured floor.
  • In lib.rs, set_min_repayment_amount now returns LoanError::InvalidAmount for negative input instead of panicking.
  • The underflow path in adjust_total_outstanding is still a panic, but it is now documented as an internal invariant that should be unreachable from normal inputs.
  • In lib.rs, cooldown enforcement now returns PoolError::WithdrawalCooldownActive instead of panicking.
  • The related assertions were updated in test.rs and test.rs.

I also checked editor diagnostics afterward, and there are no reported Rust errors in the touched files.

@ogazboiz ogazboiz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

verified locally last round (fmt+clippy+240 tests green) and ci is now green against the post-#36 base. clean conversion of the below-minimum repay panic and the withdrawal-cooldown panic into typed errors (RepaymentBelowMinimum, WithdrawalCooldownActive), with the should_panic tests switched to try_/assert_eq!(Err(...)). merging.

@ogazboiz ogazboiz merged commit aabf56b into LabsCrypt:main Jun 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Contracts] LoanManager uses raw panics for user-facing failures instead of typed LoanError returns

2 participants