Skip to content

Fix: Inconsistent Error Messages.#149

Merged
LaGodxy merged 1 commit intoMettaChain:mainfrom
Lansa-18:fix/inconsistent-err-msgs
Mar 29, 2026
Merged

Fix: Inconsistent Error Messages.#149
LaGodxy merged 1 commit intoMettaChain:mainfrom
Lansa-18:fix/inconsistent-err-msgs

Conversation

@Lansa-18
Copy link
Copy Markdown
Contributor

Closes #103

Error Message Standardization


Bug Fixes

  • OracleError::BatchSizeExceeded — replaced hardcoded literal 4012 with named constant oracle_codes::ORACLE_BATCH_SIZE_EXCEEDED
  • compliance_registry::Error — fixed 8 error variants that were mapped to wrong or duplicate codes (e.g. HighRisk, ProhibitedJurisdiction, InvalidRiskScore, and JurisdictionNotSupported all incorrectly shared COMPLIANCE_CHECK_FAILED)

New Infrastructure

Addition Description
ErrorMessage struct Standardized snapshot combining code, category, message, description, and i18n_key into a single type
ContractError::error_i18n_key() New default trait method returning a "category.variant" dot-notation key (e.g. "compliance.not_verified")
ContractError::to_error_message() New default trait method that builds an ErrorMessage from any error, zero allocation
i18n.rs module New localization module with SupportedLocale, LocalizedMessage, lookup(), and lookup_default() using static match-based lookup (fully no_std compatible)

New Constants

  • oracle_codes::ORACLE_BATCH_SIZE_EXCEEDED = 4012
  • 8 new compliance_codes constants: COMPLIANCE_HIGH_RISK through COMPLIANCE_DATA_RETENTION_EXPIRED (6006–6013)

Localization Keys

All 38 keys implemented across four categories:

common.* · oracle.* · compliance.* · monitoring.*


Tests

9 unit tests covering:

  • Unique compliance codes
  • i18n key correctness
  • to_error_message() field population
  • Known/unknown key lookup
  • lookup_default() consistency

@drips-wave
Copy link
Copy Markdown

drips-wave bot commented Mar 29, 2026

@Lansa-18 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

@Lansa-18
Copy link
Copy Markdown
Contributor Author

@LaGodxy Kindly go through chief.

@LaGodxy LaGodxy merged commit a845da6 into MettaChain:main Mar 29, 2026
16 checks passed
@Lansa-18 Lansa-18 deleted the fix/inconsistent-err-msgs branch March 30, 2026 08:48
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.

Inconsistent Error Messages

2 participants