|
|
|
|
|
by sergiosgc
4747 days ago
|
|
You don't need to leak abstractions on exceptions. Libraries should wrap the exceptions and provide meaningful exceptions, not dependent on the exact implementation. Example: public String setCache(String key, String value) throws CacheUnavailableException,CacheWriteException {
try {
...
} catch (SocketException e) {
throw new CacheUnavailableException(e);
} catch (SomeMemcacheException e) {
throw new CacheWriteException(e);
}
}
This will allow library clients to catch exceptions that mean something to them, not exceptions that only make sense if you know how the library is using memcache. |
|