Refactor/364 error handling patterns#445
Merged
Xhristin3 merged 14 commits intorinafcode:mainfrom Apr 28, 2026
Merged
Conversation
…ol, analytics, bridge, and reputation modules
|
@Oluwasuyi-Timilehin Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
…lidation in EscrowError enum
Contributor
|
@Oluwasuyi-Timilehin resolve conflicts. |
….com/Oluwasuyi-Timilehin/teachLink_contract into refactor/364-error-handling-patterns
… readability and maintainability
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#closes #364
Summary
This PR standardizes error handling behavior in the TeachLink contract for assignment #364 by removing silent failures and enforcing explicit Result propagation in the modified bridge/rewards/access paths.
What changed
Updated contracts/teachlink/src/lib.rs contract entrypoints to return and propagate errors instead of discarding them.
add_validator, remove_validator, add_supported_chain, remove_supported_chain, set_fee_recipient now return Result<(), BridgeError>.
record_course_completion now returns Result<(), BridgeError>.
Reputation wrappers now return Result<(), ReputationError>.
Rewards wrappers now return Result (update_rewards_admin, get_rewards_admin).
Updated contracts/teachlink/src/bridge.rs to eliminate silent/ignored outcomes.
Replaced ignored get_current_nonce result with explicit propagation.
Ensured all access-control role checks are propagated and mapped to BridgeError::Unauthorized.
Replaced unwrap-based config reads in touched paths with explicit error mapping.
Updated contracts/teachlink/src/rewards.rs.
Removed .ok()-based silent ignore during test bootstrap init.
Replaced unwrap-style storage reads (TOKEN, REWARDS_ADMIN) with explicit StorageError propagation.
Made admin getter/update APIs return Result consistently.
Acceptance criteria mapping
Use Result types consistently: state-changing wrappers now expose Result instead of dropping failures.
Create specific error variants: existing module-specific errors (BridgeError, RewardsError, ReputationError) are used in propagation paths.
Ensure proper propagation: failing calls now use ?/map_err(...) in touched modules.
Eliminate silent failures: removed let _ = ... and .ok() patterns in assignment scope.
Risk / Compatibility notes
Function signatures changed for several public contract entrypoints; downstream callers/tests/SDK bindings may need to handle returned Result values where they previously ignored return values.
Behavioral change is intentional: operations now fail explicitly instead of silently succeeding.
Test plan
cargo fmt --all
cargo clippy --all-targets --all-features -- -D warnings
cargo test -p teachlink-contract
Verify no silent bridge wrapper calls remain:
rg "let _ = bridge::Bridge::" contracts/teachlink/src/lib.rs
Verify no .ok() silent ignores in rewards touched path:
rg ".ok()" contracts/teachlink/src/rewards.rs
Spot-check role check propagation in bridge module:
rg "check_role(" contracts/teachlink/src/bridge.rs
#closes