Add comprehensive error types and error handling - #126
Merged
manoahLinks merged 2 commits intoMar 28, 2026
Merged
Conversation
event_manager: - Add error variants: EventNotCanceled(11), RefundAlreadyClaimed(12), NotABuyer(13), EventSoldOut(14), TicketsBelowSold(15) - Convert claim_refund, update_event, purchase_ticket to return Result - Update tests from #[should_panic] to try_ assertions ticket_nft: - Add NotInitialized(5) error variant - Convert burn, get_minter to return Result - Replace .unwrap() in mint_ticket_nft with typed error tba_registry: - Add NotInitialized(2) error variant - Replace .expect() in create_account with typed error ticket_factory: - Add new Error enum with NotInitialized(1), Unauthorized(2) - Convert deploy_ticket, get_admin to return Result tba_account: - Already uses typed errors throughout (no changes needed)
|
@Wetshakat 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! 🚀 |
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.
closed #79
Add Comprehensive Error Types and Error Handling
Summary
Replaces all panic!(), .expect(), and untyped .unwrap() calls across every contract with
typed #[contracterror] error enums and Result return types. This gives callers
structured, machine-readable error codes instead of opaque panic strings.
Motivation
String-based panics make it impossible for frontend clients and integrators to
programmatically handle errors. Typed error enums with numeric codes allow:
Changes by Contract
event_manager
5 new error variants added:
Functions converted to Result:
Also removed a dangling duplicate panic!("Ticket factory not initialized") line in
deploy_ticket_nft helper.
ticket_nft
1 new error variant:
Functions converted to Result:
tba_registry
1 new error variant:
Changed in create_account: .expect() → .ok_or(Error::NotInitialized)?
ticket_factory
Entirely new Error enum (contract had none):
Functions converted to Result:
tba_account
No changes needed — already used typed errors throughout.
Test Updates
assertions
get_minter calls
Files Changed
How to Verify
contract's non-test code
in ticket_nft and tba_account)