Practice ยท 2 of 3
Translate at the Boundary
Implement a storage boundary inside Solution:
- static class StorageException extends RuntimeException with
(String message, Throwable cause) constructor.
- static class FlakyStore with static String fetch(String key):
returns "data-" + key, but throws IllegalStateException("boom")
when the key starts with "!".
- static String repositoryGet(String key) โ calls fetch and translates
any IllegalStateException into StorageException("lookup failed for " + key, e),
chaining the original cause.
Callers of repositoryGet must never see IllegalStateException.
Difficulty: intermediate
Press Submit to check your solution.
Back to lesson: Practice: Exception Architecture Lab