domain-errors
CommunityHarmonize domain error handling across services
Software Engineering#error-handling#prisma#saas#nestjs#domain-errors#zod-validation#exception-filters
Authorjohnnystefan
Version1.0.0
Installs0
System Documentation
What problem does it solve?
Business domain errors across the SaaS services lack a shared structure and HTTP mapping, making it hard to handle business rule violations, validation issues, and resource failures consistently.
Core Features & Use Cases
- Base DomainError class provides typed codes, titles, messages, and context so every service defines errors from a single contract rooted in libs/shared/types/src/errors/domain-error.ts.
- Concrete errors and validation such as ResourceNotFoundError, BusinessRuleViolationError, InvalidArgumentError, and DomainValidationError encapsulate rich context, offer convenient static factories, and integrate Zod safeParse results.
- NestJS DomainErrorFilter maps the typed codes to HTTP statuses and can be registered globally to ensure consistent client responses across auth, club, inventory, booking, finance, and shared libraries.
- Use Case: When a booking rule is violated, throw BusinessRuleViolationError so the exception filter returns a 422 response with a consistent code and message.
Quick Start
Define a DomainError subclass for your resource and register the DomainErrorFilter to translate errors into HTTP responses.
Dependency Matrix
Required Modules
None requiredComponents
Standard package💻 Claude Code Installation
Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.
Please help me install this Skill: Name: domain-errors Download link: https://github.com/johnnystefan/test-saas-business/archive/main.zip#domain-errors Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
Agent Skills Search Helper
Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.