Skip to content

Fix invalid quest ID error handling, #229

Open
gerani1 wants to merge 1 commit into
MindFlowInteractive:mainfrom
gerani1:fix/issue-211-quest-errors
Open

Fix invalid quest ID error handling, #229
gerani1 wants to merge 1 commit into
MindFlowInteractive:mainfrom
gerani1:fix/issue-211-quest-errors

Conversation

@gerani1
Copy link
Copy Markdown

@gerani1 gerani1 commented May 27, 2026

Description

closes #211.

This PR significantly improves the developer experience and contract robustness by removing raw panic! strings and replacing them with a formal QuestChainError enum using Soroban's #[contracterror] attribute. This standardization allows front-end clients and indexers to parse and handle explicit error codes instead of arbitrary panic strings.

Key Changes

  • Introduced QuestChainError Enum: Defined a standardized set of explicit error variants (e.g., AlreadyInitialized, InvalidAdmin, InvalidChainId, QuestNotFound) covering all contract validation failures.
  • Refactored Contract Panics: Migrated all generic panic!(...) occurrences inside QuestChainContract to use soroban_sdk::panic_with_error!(&env, QuestChainError::Variant).
  • Updated Test Suite:
    • Adjusted all #[should_panic] assertions across the quest_chain test suite to expect the new typed format (e.g., expected = "Error(Contract, #N)").
    • Addressed pre-existing logic bugs in tests (like missing initialization arguments and invalid whitespace in Symbol instantiation) to ensure the test suite compiles and runs flawlessly with the new changes.

Verification

  • All unit tests in contracts/quest_chain compile and pass.
  • Error codes successfully emit via HostError to standard Soroban events payload.
  • Unused testing variables were cleaned up.

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 27, 2026

@gerani1 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

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.

Improve Invalid Quest ID Error Handling

2 participants