Skip to content

Commit

Permalink
Improve error logging related to asset resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
pablode committed Jul 13, 2024
1 parent 2ea86bf commit a837281
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/libguc/src/cgltf_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,24 @@ namespace detail
ArResolvedPath resolvedPath = resolver.Resolve(path);
if (!resolvedPath)
{
TF_RUNTIME_ERROR("unable to resolve %s", path);
return cgltf_result_file_not_found;
}

TF_DEBUG(GUC).Msg("resolved path to %s\n", resolvedPath.GetPathString().c_str());
std::string resolvedPathStr = resolvedPath.GetPathString();
TF_DEBUG(GUC).Msg("resolved path to %s\n", resolvedPathStr.c_str());

std::shared_ptr<ArAsset> asset = resolver.OpenAsset(ArResolvedPath(path));
if (!asset)
{
TF_RUNTIME_ERROR("unable to open asset %s", resolvedPathStr.c_str());
return cgltf_result_file_not_found;
}

std::shared_ptr<const char> buffer = asset->GetBuffer();
if (!buffer)
{
TF_RUNTIME_ERROR("unable to open buffer for %s", resolvedPathStr.c_str());
return cgltf_result_io_error;
}

Expand Down
6 changes: 5 additions & 1 deletion src/libguc/src/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,20 +119,24 @@ namespace detail
ArResolvedPath resolvedPath = resolver.Resolve(path);
if (!resolvedPath)
{
TF_RUNTIME_ERROR("unable to resolve %s", path);
return false;
}

TF_DEBUG(GUC).Msg("resolved image to %s\n", resolvedPath.GetPathString().c_str());
std::string resolvedPathStr = resolvedPath.GetPathString();
TF_DEBUG(GUC).Msg("resolved image to %s\n", resolvedPathStr.c_str());

std::shared_ptr<ArAsset> asset = resolver.OpenAsset(resolvedPath);
if (!asset)
{
TF_RUNTIME_ERROR("unable to open asset %s", resolvedPathStr.c_str());
return false;
}

std::shared_ptr<const char> buffer = asset->GetBuffer();
if (!buffer)
{
TF_RUNTIME_ERROR("unable to open buffer for %s", resolvedPathStr.c_str());
return false;
}

Expand Down

0 comments on commit a837281

Please sign in to comment.