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.
In more detail
A repository that lets a storage library's exception escape forces services and controllers to know about storage, and a library upgrade can then change your public signatures. Translating to a stable domain exception stops that leak. At the web boundary, a further translation turns domain exceptions into HTTP responses.
Related terms
- exception chaining — Linking a new exception to the one that caused it, so the higher-level failure still carries the original error and its stack trace.
- domain exception — An exception named for a business situation, such as OrderMissing or StorageFailure, rather than for a technical cause.
- checked exception — An exception type that the compiler forces every caller to either catch or declare with throws, making the failure part of the method's contract.
- controller advice — A Spring class, marked @RestControllerAdvice, whose exception handlers apply across all controllers, giving one failure policy for every route.
Taught in
- The Cost Of Checked Exceptions — Modern Java: Virtual Threads & High-Throughput Services
- Async With CompletableFuture — Modern Java: Virtual Threads & High-Throughput Services
- Exception Handling To Problem Details — Modern Java: Virtual Threads & High-Throughput Services