Skip to content

Replace panic!/panic_with_error! with typed errors; add missing error…#184

Open
happyboy24 wants to merge 1 commit into
Bitcoindefi:mainfrom
happyboy24:stellar-passport
Open

Replace panic!/panic_with_error! with typed errors; add missing error…#184
happyboy24 wants to merge 1 commit into
Bitcoindefi:mainfrom
happyboy24:stellar-passport

Conversation

@happyboy24

@happyboy24 happyboy24 commented Jun 29, 2026

Copy link
Copy Markdown

… tests

  • Convert init() from panic_with_error!(AlreadyInitialized) to return Err(Error::AlreadyInitialized); change signature to Result<(), Error> so callers get a typed error not a trap
  • Replace accept_admin ok_or(NotInitialized) with the new NoPendingAdmin variant for accurate error semantics
  • Add NoPendingAdmin = 8 to the Error enum
  • Doc-comment every Error variant for ABI documentation
  • Remove now-unused panic_with_error import
  • Convert init_is_one_shot test from #[should_panic] to try_init + assert_eq!(Err(Ok(Error::AlreadyInitialized)))
  • Add 9 new tests covering NotInitialized on all admin entry- points and NoPendingAdmin on accept_admin

All 26 tests pass; grep confirms zero panic!/unwrap()/expect() in contract source.

Summary

Checklist

… tests

- Convert init() from panic_with_error!(AlreadyInitialized) to
  return Err(Error::AlreadyInitialized); change signature to
  Result<(), Error> so callers get a typed error not a trap
- Replace accept_admin ok_or(NotInitialized) with the new
  NoPendingAdmin variant for accurate error semantics
- Add NoPendingAdmin = 8 to the Error enum
- Doc-comment every Error variant for ABI documentation
- Remove now-unused panic_with_error import
- Convert init_is_one_shot test from #[should_panic] to
  try_init + assert_eq!(Err(Ok(Error::AlreadyInitialized)))
- Add 9 new tests covering NotInitialized on all admin entry-
  points and NoPendingAdmin on accept_admin

All 26 tests pass; grep confirms zero panic!/unwrap()/expect() in
contract source.
@happyboy24 happyboy24 requested a review from leocagli as a code owner June 29, 2026 19:28
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.

Audit: review all panic! sites in the validator contract and replace with proper errors

1 participant