domain-exception-hierarchy

Define a three-tier domain exception hierarchy with adapter translation and retry handlers.

Updated Apr 16, 2026
One-click install
npx skills add https://github.com/luansilvadb/agoravai --skill domain-exception-hierarchy
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: domain-exception-hierarchy
Source: https://github.com/luansilvadb/agoravai/tree/main/.rag/context/domain-exception-hierarchy
Command: npx skills add https://github.com/luansilvadb/agoravai --skill domain-exception-hierarchy

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Creates a structured, semantic domain exception hierarchy to ensure precise error diagnosis, consistent propagation, and safe cross-layer boundaries.

Core Features & Use Cases

  • Abstract base with contract: a sealed domain exception base carrying code, context, timestamp, and cause.
  • Categorized leaves with typed context: specialized exceptions for Validation, State, Infrastructure, and Business errors with strong typing.
  • Adapter translation & resilience: one-way translation from infra to domain, plus layered handlers (retry/fallback) and API-friendly payloads.
  • Audit and observability: ensures exceptions are actionable and traceable across domain, application, and infrastructure.

Quick Start

Create an abstract base exception with a typed context, then implement category leaves and an adapter translator.

Frequently Asked Questions about domain-exception-hierarchy

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I model domain exceptions in TypeScript to preserve error context across layers?

You model domain exceptions by implementing a typed three-tier hierarchy: an abstract base exception carrying code, context, timestamp, and cause; categorized leaves; and an adapter translator. This structure preserves diagnostic context and propagates errors consistently across clean architecture layers.

What is a three-tier domain exception hierarchy in clean architecture?

A three-tier domain exception hierarchy consists of a base exception class defining the contract, category-level exceptions grouping related business errors, and leaf exceptions carrying specific typed context. This categorization ensures precise error diagnosis and safe cross-layer boundaries in clean architecture.

How do I translate infrastructure errors to domain exceptions in TypeScript?

You translate infrastructure errors using a one-way adapter translation mechanism. This maps external infrastructure failures into semantic domain exceptions, maintaining consistency and observability while preventing infrastructure details from leaking into the domain layer.

Does this domain exception approach include retry and fallback handlers for infrastructure errors?

Yes, the domain exception hierarchy includes layered resilience handlers for retry and fallback. These handlers intercept translated infrastructure exceptions, apply recovery policies, and ensure that business errors remain actionable and traceable across the application and infrastructure layers.

How do I serialize domain exceptions to API-friendly payloads?

Leaf exceptions in the hierarchy serialize to API-friendly payloads by leveraging their strongly typed context and error codes. This ensures the serialized output contains structured diagnostic information needed for consistent client-side error handling and audit observability.