Skip to content

Commit ed96f35

Browse files
committed
cache exception and log
1 parent 414a562 commit ed96f35

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/main/java/com/wego/httpcache/services/impl/CachedResponseServiceImpl.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@
66
import com.wego.httpcache.dao.mappers.CachedResponseToCachedResponseEntity;
77
import com.wego.httpcache.dao.models.CachedResponse;
88
import com.wego.httpcache.services.CachedResponseService;
9+
import java.io.IOException;
910
import java.util.Optional;
11+
import org.slf4j.Logger;
12+
import org.slf4j.LoggerFactory;
1013

1114
public class CachedResponseServiceImpl implements CachedResponseService {
15+
private static final Logger LOGGER = LoggerFactory.getLogger(CachedResponseServiceImpl.class);
1216

1317
@Inject private CachedResponseDao cachedResponseDao;
1418

@@ -22,7 +26,11 @@ public CachedResponse save(CachedResponse cachedResponse, long ttl) {
2226
return null;
2327
}
2428

25-
cachedResponseDao.save(responseToHttpReponseEntity.transform(cachedResponse), ttl);
29+
try {
30+
cachedResponseDao.save(responseToHttpReponseEntity.transform(cachedResponse), ttl);
31+
} catch (IOException e) {
32+
LOGGER.error("Error saving cachedResponse with id {}", cachedResponse.getId(), e);
33+
}
2634

2735
return cachedResponse;
2836
}

0 commit comments

Comments
 (0)