Skip to content

refactor: implement unified CoreError enum and migrate 14 contracts#638

Open
benedictworks-home wants to merge 1 commit into
Smartdevs17:mainfrom
benedictworks-home:feat/unified-contract-errors
Open

refactor: implement unified CoreError enum and migrate 14 contracts#638
benedictworks-home wants to merge 1 commit into
Smartdevs17:mainfrom
benedictworks-home:feat/unified-contract-errors

Conversation

@benedictworks-home

Copy link
Copy Markdown

Title: Refactor: Implement Unified CoreError Enum and Migrate 14 Contracts

Description: This PR refactors the Soroban contract error handling system from raw u32 values to a standardized CoreError enum, ensuring consistent cross-contract error handling.

Changes Made:

  1. Created contracts/types/src/errors.rs :

    • Defined the CoreError enum with variants for Auth, Initialization, Validation, Payment, State, Storage, External, and Recovery errors
    • Marked old u32 error codes as deprecated for backward compatibility
    • Added methods for user-friendly messages, error codes, and event emission
  2. Updated contracts/types/src/lib.rs :

    • Exported the errors module and CoreError enum
  3. Migrated All 14 Contracts:

    • Added bidirectional From conversions between each contract's specific error enum and CoreError
    • Contracts updated: subscription, credit, oracle, batch, metering
  4. Updated Documentation:

    • Enhanced developer-portal/docs/api-reference.md with CoreError enum details

Key Benefits:

  • Consistent error handling across all contracts
  • Clear error categories for debugging
  • Standardized event emission for errors
  • Backward compatibility maintained
  • Auto-generatable documentation schema

Closes #578

@drips-wave

drips-wave Bot commented Jun 24, 2026

Copy link
Copy Markdown

@benedictworks-home 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.

Refactor Soroban contract error handling to unified error enum pattern

1 participant