Skip to content

Commit

Permalink
refactor error printing
Browse files Browse the repository at this point in the history
  • Loading branch information
pasotee committed Aug 31, 2024
1 parent a6b0575 commit 0d15e15
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions Source/ConfigCat/Private/ConfigCatSubsystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,23 @@ using namespace configcat;

namespace
{
void PrintError(const FString& ErrorMessage)
{
if (GEngine)
{
GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Red, FString::Printf(TEXT("[ConfigCat] %s"), *ErrorMessage));
}
UE_LOG(LogConfigCat, Error, TEXT("%s"), *ErrorMessage);
}

bool EnsureConfigCatClient(const std::shared_ptr<configcat::ConfigCatClient>& Client)
{
if (Client)
{
return true;
}

UE_LOG(LogConfigCat, Error, TEXT("Trying to access the ConfigCatClient before initialization or after shutdown."));
if(GEngine)
{
GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Red, TEXT("Trying to access the ConfigCatClient before initialization or after shutdown."));
}

PrintError(TEXT("Trying to access the client before initialization or after shutdown."));
return false;
}

Expand Down Expand Up @@ -284,12 +288,7 @@ void UConfigCatSubsystem::Initialize(FSubsystemCollectionBase& Collection)
const UConfigCatSettings* ConfigCatSettings = GetDefault<UConfigCatSettings>();
if (!ConfigCatSettings || ConfigCatSettings->SdkKey.IsEmpty())
{
if(GEngine)
{
GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Red, TEXT("ConfigCat SdkKey missing. Please set your SdkKey in the Project Settings."));
}

UE_LOG(LogConfigCat, Error, TEXT("ConfigCat SdkKey missing. Please set your SdkKey in the Project Settings."));
PrintError(TEXT("SdkKey missing. Please set your SdkKey in the Project Settings."));
return;
}

Expand Down

0 comments on commit 0d15e15

Please sign in to comment.