Skip to content

Define Custom Error Enum for Vault Contract #17

@greatest0fallt1me

Description

@greatest0fallt1me

Description
Replace panics with a custom error enum where appropriate (e.g. NotInitialized, Unauthorized, InsufficientBalance, InvalidAmount) and return Result from functions or use panic with consistent error messages for Soroban.

Requirements and context

  • Must be secure, tested, and documented
  • Should be efficient and easy to review
  • Soroban often uses panic for revert; if using Result, document ABI impact. Alternatively standardize panic messages via an error enum and panic with same message.
  • Ensure frontend/backend can parse or detect failure reasons

Suggested execution

  • Fork the repo and create a branch
  • git checkout -b feature/vault-error-enum
  • Implement changes
    • Define enum VaultError with variants; add helper that panics with same message per variant
    • Replace assert! and panic! with these helpers
    • Update tests to expect specific panic messages or error results
  • Test and commit
    • Run tests; document error contract
    • Include test output
  • Example commit message: feat: vault custom error enum and consistent panic messages

Guidelines

  • Minimum 95 percent test coverage
  • Clear documentation
  • Timeframe: 96 hours
  • Project details: #

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave program

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions