domain exception
An exception named for a business situation, such as OrderMissing or StorageFailure, rather than for a technical cause.
In more detail
Domain exceptions give each layer one stable type to handle, independent of which library failed underneath. Controller advice can map each one to a suitable HTTP status and problem details body.
Example
@ExceptionHandler(OrderMissing.class)Related terms
- exception translation — Catching a low-level exception at a boundary and throwing a higher-level one that fits the caller's vocabulary, keeping the original as the cause.
- unchecked exception — An exception type, extending RuntimeException, that the compiler does not force callers to catch or declare.
- controller advice — A Spring class, marked @RestControllerAdvice, whose exception handlers apply across all controllers, giving one failure policy for every route.
Taught in
- Checked Versus Unchecked Exceptions — Modern Java: Virtual Threads & High-Throughput Services
- The Cost Of Checked Exceptions — Modern Java: Virtual Threads & High-Throughput Services
- Exception Handling To Problem Details — Modern Java: Virtual Threads & High-Throughput Services