Skip to content

Commit

Permalink
Prevent crash for missing settings or empty SDK key
Browse files Browse the repository at this point in the history
  • Loading branch information
pasotee committed Jan 31, 2024
1 parent 06c51f2 commit f3f5d4e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Source/ConfigCat/Private/ConfigCatSubsystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,18 @@ bool UConfigCatSubsystem::IsOffline() const

void UConfigCatSubsystem::Initialize(FSubsystemCollectionBase& Collection)
{
const FString CppSdkVersion = UTF8_TO_TCHAR(configcat::version);
UE_LOG(LogConfigCat, Display, TEXT("ConfigCat Subsystem initializing cpp-sdk - %s"), *CppSdkVersion);

const UConfigCatSettings* ConfigCatSettings = GetDefault<UConfigCatSettings>();
if(!ConfigCatSettings || ConfigCatSettings->SdkKey.IsEmpty())
{
UE_LOG(LogConfigCat, Warning, TEXT("Empty SdkKey detected. Please set your SdkKey in the Project Settings."));
return;
}

const std::string& SdkKey = TCHAR_TO_UTF8(*ConfigCatSettings->SdkKey);

const FString CppSdkVersion = UTF8_TO_TCHAR(configcat::version);
UE_LOG(LogConfigCat, Display, TEXT("ConfigCat Subsystem initializing cpp-sdk - %s"), *CppSdkVersion);

ConfigCatOptions Options;
Options.baseUrl = TCHAR_TO_UTF8(*ConfigCatSettings->BaseUrl);
Options.dataGovernance = ConfigCatSettings->DataGovernance == EDataGovernance::Global ? Global : EuOnly;
Expand Down

0 comments on commit f3f5d4e

Please sign in to comment.