Skip to content

refactors and hardens the MessageFactory#39

Merged
Rashed99Azm merged 1 commit into
developfrom
feat/refactor-error-codes
Jun 1, 2026
Merged

refactors and hardens the MessageFactory#39
Rashed99Azm merged 1 commit into
developfrom
feat/refactor-error-codes

Conversation

@Rashed99Azm

Copy link
Copy Markdown
Collaborator

Summary

This PR refactors and hardens the MessageFactory pipeline to improve reliability, observability, and localization integrity while removing the legacy Errors infrastructure.

Changes

Localization Integrity Validation

  • Added SystemCodeMapIntegrityTests to validate:
    • Every SystemCodeMap key has both Arabic and English translations.
    • No duplicate system codes exist.
    • Every SystemCode constant value matches its field name.
  • Linked Resources.yaml into Application.Tests output to ensure YamlLocalizationStore can resolve translations during test execution.

Improved Observability

  • Injected ILogger<MessageFactory> into MessageFactory.
  • Added warning logs when:
    • ResolveCode() falls back to ERR900 due to an unmapped key.
    • Localize() returns the original key because a translation is missing.
  • Standardized all six MessageFactory entry points to use the shared resolution and localization pipeline.

Legacy Errors System Removal

  • Removed CCE.Application.Common.Errors.
  • Removed the related DI registration.
  • Confirmed no remaining runtime injection or usage sites.
  • Deleted 44 obsolete localization keys, including legacy:
    • IDENTITY_*
    • CONTENT_*
    • COMMUNITY_*
    • COUNTRY_COUNTRY_*
    • GENERAL_*
    • NOTIFICATIONS_*
    • VALIDATION_*

Bug Fixes

Fixed three cases that silently fell back to ERR900:

Key | Code -- | -- COUNTRY_CODE_NOT_FOUND | ERR130 LOOKUP_CREATED | CON070 LOOKUP_UPDATED | CON071

Added the missing entries to both SystemCode and SystemCodeMap.

Translation Coverage

  • Added approximately 60 missing Arabic and English translations.
  • Ensured every SystemCodeMap entry resolves successfully from Resources.yaml.
  • Future regressions are prevented by the new integrity test suite.

ApplicationErrors Standardization

Added new domain groups:

  • PlatformSettings
  • Media
  • Verification
  • Lookups

Refactored all 35 MessageFactory convenience methods to use ApplicationErrors.* constants, eliminating remaining hardcoded string literals.

Result

  • No silent localization failures.
  • No silent code-to-error fallbacks.
  • Full translation coverage for all mapped system codes.
  • Improved diagnostics through structured logging.
  • Removal of unused legacy error infrastructure.
  • Centralized and strongly-typed error key management.

…move legacy Errors system

  Phase 1 — integrity test: add SystemCodeMapIntegrityTests asserting every
  SystemCodeMap domain key has ar+en translations, no duplicate codes, and
  every SystemCode constant value matches its field name. Link Resources.yaml
  into Application.Tests output so YamlLocalizationStore finds it at test time.

  Phase 2 — observable fallbacks: inject ILogger<MessageFactory>; ResolveCode()
  logs Warning when a key falls back to ERR900, Localize() logs Warning when
  GetString returns the raw key unchanged. All 6 entry points route through
  these helpers.

  Phase 4 — legacy removal:
  - Delete CCE.Application.Common.Errors and its DI registration (no live
    injection sites); 44 prefixed legacy yaml keys removed (IDENTITY_*,
    CONTENT_*-prefixed, COMMUNITY_*, COUNTRY_COUNTRY_*, GENERAL_*,
    NOTIFICATIONS_*-prefixed, VALIDATION_*-prefixed duplicates).
  - Fix 3 silent ERR900 bugs: add COUNTRY_CODE_NOT_FOUND (ERR130),
    LOOKUP_CREATED (CON070), LOOKUP_UPDATED (CON071) to SystemCode +
    SystemCodeMap.
  - Add ~60 missing ar+en translations so every SystemCodeMap key resolves
    in Resources.yaml (integrity test enforces this going forward).
  - Extend ApplicationErrors with PlatformSettings, Media, Verification,
    Lookups domain classes; standardize all 35 MessageFactory convenience
    shortcuts to ApplicationErrors.* constants — zero bare string literals.
@Rashed99Azm Rashed99Azm merged commit b3aab56 into develop Jun 1, 2026
ayman-aboelabbas pushed a commit that referenced this pull request Jun 16, 2026
- Post-detail: load author profile in background so replies and post render
  immediately; remove profileLoading toggle that was hiding the sidebar
- Follow author: unwrap API envelope in getMyFollows(), add defensive ?? []
  fallbacks in idsFor(), fix template binding ([entityType]="'user'") and
  guard @if with authorId() to prevent empty-string entityId
- Reply upvote icon: change arrow-up to arrow-big-up to match post upvote
- News card excerpt: decode HTML entities (&nbsp;, &#39;, etc.) before
  displaying plain-text excerpt so raw entity strings no longer appear
- News list grid: use minmax(0, 1fr) columns so aspect-ratio cards with no
  text content cannot blow out the grid column width
- News detail body: replace &nbsp; /   with regular spaces in
  contentHtml() so Arabic text wraps correctly; add overflow-wrap and
  max-width safeguards to body CSS
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.

2 participants