Add MCPErrorCallback. Simplify error handling.
This commit is contained in:
@@ -200,7 +200,7 @@ FAssetData* UMCPAssetFinder::FindAnyAsset(const FString& NameOrPath, FString* Ou
|
||||
// Load helpers
|
||||
// ============================================================
|
||||
|
||||
UBlueprint* UMCPAssetFinder::LoadBlueprintOrLevelBlueprint(FAssetData& Asset, FString& OutError)
|
||||
UBlueprint* UMCPAssetFinder::LoadBlueprintOrLevelBlueprint(FAssetData& Asset, MCPErrorCallback Error)
|
||||
{
|
||||
// Regular blueprint asset
|
||||
UBlueprint* BP = Cast<UBlueprint>(Asset.GetAsset());
|
||||
@@ -214,20 +214,22 @@ UBlueprint* UMCPAssetFinder::LoadBlueprintOrLevelBlueprint(FAssetData& Asset, FS
|
||||
if (LevelBP) return LevelBP;
|
||||
}
|
||||
|
||||
OutError = FString::Printf(TEXT("Asset '%s' loaded but its level blueprint could not be retrieved."),
|
||||
*Asset.AssetName.ToString());
|
||||
Error.SetError(FString::Printf(TEXT("Asset '%s' loaded but its level blueprint could not be retrieved."),
|
||||
*Asset.AssetName.ToString()));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
UBlueprint* UMCPAssetFinder::LoadBlueprintOrLevelBlueprint(const FString& NameOrPath, FString& OutError)
|
||||
UBlueprint* UMCPAssetFinder::LoadBlueprintOrLevelBlueprint(const FString& NameOrPath, MCPErrorCallback Error)
|
||||
{
|
||||
FAssetData* Asset = FindAsset(BlueprintsAndMaps, NameOrPath, &OutError);
|
||||
FString FindError;
|
||||
FAssetData* Asset = FindAsset(BlueprintsAndMaps, NameOrPath, &FindError);
|
||||
if (!Asset)
|
||||
{
|
||||
if (OutError.IsEmpty())
|
||||
OutError = FString::Printf(TEXT("Blueprint '%s' not found."), *NameOrPath);
|
||||
if (FindError.IsEmpty())
|
||||
FindError = FString::Printf(TEXT("Blueprint '%s' not found."), *NameOrPath);
|
||||
Error.SetError(FindError);
|
||||
return nullptr;
|
||||
}
|
||||
return LoadBlueprintOrLevelBlueprint(*Asset, OutError);
|
||||
return LoadBlueprintOrLevelBlueprint(*Asset, Error);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user