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.