Install
1
Install the plugin$
npx claudepluginhub allousas/claude-code-plugins --plugin kotlin-cross-cuttingWant just this skill?
Add to a custom plugin, then install with one command.
Description
Apply when creating, refactoring, changing, planning (plan mode) or reviewing any code that handles errors using exceptions. This includes adding, modifying, or fixing custom exception classes, DomainException hierarchies, GlobalExceptionHandler, @ExceptionHandler methods, exception propagation, or error code mappings.
Tool Access
This skill uses the workspace's default tool permissions.
Supporting Assets
View in Repositoryexamples.mdSkill Content
Purpose
Define a consistent exception hierarchy so domain and infrastructure errors propagate cleanly to infrastructure boundaries where they are translated into appropriate responses (HTTP status codes, Kafka DLQ, etc.).
Strategy
- Domain layer throws domain-specific exceptions to signal business rule violations
- Application services let domain exceptions propagate (no catch)
- Infrastructure adapters (controllers, consumers) let exceptions reach global handlers
- Infrastructure exceptions (DB failures, HTTP client errors) are separate from domain exceptions and defined close to the infrastructure layer
Guidelines
DO:
- Apply the Let It Fail principle: do not defensively catch domain exceptions just to log or rethrow — allow them to propagate to the appropriate boundary (e.g., API layer or global handler)
- Create a sealed
DomainExceptionbase class for all domain errors - Mark any method throwing a domain exception as
throws, just for minimal visibility - Create specific exception subclasses for each business error case (e.g.,
TeamCreationException) - Throw domain exceptions in domain entities or domain services only
- Let exceptions propagate naturally through application services without catching
- Use separate infrastructure exceptions for infra failures (DB, HTTP client, Kafka) (e.g.,
HttpFailureException) - Create infrastructure-specific exceptions only when you’re adding meaningful context or converting low-level failures into something your application understands; otherwise, let them propagate instead of wrapping them unnecessarily.
- Include meaningful error codes for API consumers (e.g.,
"TEAM_NOT_FOUND","MEMBER_LIMIT_REACHED")
DON'T:
- Catch and rethrow domain exceptions in application services - let them propagate
- Use generic exceptions (
RuntimeException,IllegalStateException) for domain errors - Throw domain exceptions from infrastructure adapters (repositories, HTTP clients) - use infrastructure exceptions instead
- Use try-catch in controllers - delegate to
GlobalExceptionHandler - Mix domain and infrastructure exception hierarchies
- Don't catch exceptions just to log and rethrow - let them propagate to global handlers for consistent logging and response mapping
Spring specifics
- Use
@ControllerAdvicewith@ExceptionHandlermethods inGlobalExceptionHandler - One handler method per exception type, mapping to the correct HTTP status
- Log all exceptions with use case context in the handler
Examples
Please use always these examples as reference: examples.md
Stats
Stars1
Forks0
Last CommitFeb 25, 2026
Actions