Skip to content

Add get_escrow not-found error handling instead of .expect() #332

Description

@Codex723

Summary

get_escrow(), release(), and refund() all use .expect("Escrow not found"), which panics with a generic message. Consider using
soroban_sdk::contracterror for typed, documented error codes instead.

Difficulty

Intermediate — estimated effort: ~1-2 days. Labels: contracts, rust, soroban, intermediate

Where to Work

  • See relevant files referenced in the description above.

How to Approach This

  1. cd contracts/escrow and make sure you can build first: cargo build --target wasm32-unknown-unknown --release.
  2. Read the module-level doc comment at the top of src/lib.rs for the design context before changing behavior.
  3. Make your change directly in src/lib.rs (or add a new module if it's substantial, e.g. src/errors.rs).
  4. Add or update tests in src/test.rs using the Soroban Env::default() test harness — see the Soroban SDK docs for Env::register_contract and Address::generate patterns.
  5. Run cargo test locally and confirm all tests pass before opening a PR.
  6. Run cargo clippy -- -D warnings and cargo fmt --check and fix anything flagged.

Acceptance Criteria

  • Behavior described above is implemented in contracts/escrow/src/lib.rs (or the relevant module).
  • New/updated tests added in contracts/escrow/src/test.rs covering both success and failure paths.
  • cargo test passes locally.
  • cargo clippy -- -D warnings and cargo fmt --check pass with no new warnings.
  • Relevant doc comments (///) updated to match the new behavior.
  • contracts/escrow/README.md updated if this issue changes the contract's public interface or design decisions documented there.

Notes for Contributors

Comment on this issue before starting so it can be assigned to you and duplicate work is avoided. If the described approach doesn't quite fit once you're in the code (e.g. the file has moved, or there's a cleaner way to do it), that's fine — leave a comment explaining the deviation in your PR description rather than silently changing scope.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions