Add MCPErrorCallback. Simplify error handling.

This commit is contained in:
2026-03-07 01:55:32 -05:00
parent b7b28e9336
commit 282ee3ef33
13 changed files with 134 additions and 180 deletions

View File

@@ -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);
}