Skip to content

Commit 1c07850

Browse files
Add log in case DiskCache open failed (#748)
On Creating Default cache through OlpClientSettingsFactory there was not check for failure on opening DiskCache. Now in case of error proper log message is printed. Resolves: OLPSUP-9914 Signed-off-by: Serhii Lozynskyi <[email protected]>
1 parent e209f90 commit 1c07850

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

olp-cpp-sdk-core/src/client/OlpClientSettingsFactory.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,15 @@
2222
#include "olp/core/cache/CacheSettings.h"
2323
#include "olp/core/cache/DefaultCache.h"
2424
#include "olp/core/http/Network.h"
25+
#include "olp/core/logging/Log.h"
2526
#include "olp/core/porting/make_unique.h"
2627
#include "olp/core/thread/ThreadPoolTaskScheduler.h"
2728

2829
namespace olp {
2930
namespace client {
3031

32+
auto constexpr kLogTag = "OlpClientSettingsFactory";
33+
3134
std::unique_ptr<thread::TaskScheduler>
3235
OlpClientSettingsFactory::CreateDefaultTaskScheduler(size_t thread_count) {
3336
return std::make_unique<thread::ThreadPoolTaskScheduler>(thread_count);
@@ -42,7 +45,16 @@ OlpClientSettingsFactory::CreateDefaultNetworkRequestHandler(
4245
std::unique_ptr<cache::KeyValueCache>
4346
OlpClientSettingsFactory::CreateDefaultCache(cache::CacheSettings settings) {
4447
auto cache = std::make_unique<cache::DefaultCache>(std::move(settings));
45-
cache->Open();
48+
auto error = cache->Open();
49+
if (error == cache::DefaultCache::StorageOpenResult::OpenDiskPathFailure) {
50+
OLP_SDK_LOG_FATAL_F(
51+
kLogTag,
52+
"Error opening disk cache, disk_path_mutable=%s, "
53+
"disk_path_protected=%s",
54+
settings.disk_path_mutable.get_value_or("(empty)").c_str(),
55+
settings.disk_path_protected.get_value_or("(empty)").c_str());
56+
return nullptr;
57+
}
4658
return std::move(cache);
4759
}
4860

0 commit comments

Comments
 (0)