Skip to content

Refactor/364 error handling patterns#445

Merged
Xhristin3 merged 14 commits intorinafcode:mainfrom
Oluwasuyi-Timilehin:refactor/364-error-handling-patterns
Apr 28, 2026
Merged

Refactor/364 error handling patterns#445
Xhristin3 merged 14 commits intorinafcode:mainfrom
Oluwasuyi-Timilehin:refactor/364-error-handling-patterns

Conversation

@Oluwasuyi-Timilehin
Copy link
Copy Markdown
Contributor

#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

…ol, analytics, bridge, and reputation modules
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 26, 2026

@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! 🚀

Learn more about application limits

@Xhristin3
Copy link
Copy Markdown
Contributor

@Oluwasuyi-Timilehin resolve conflicts.

@Xhristin3 Xhristin3 merged commit 72f10ec into rinafcode:main Apr 28, 2026
2 of 4 checks 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.

Implement consistent error handling patterns

2 participants