Skip to content

Commit

Permalink
refactor: Use the same utility function to get vtflib errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ENDERZOMBI102 committed Jan 21, 2024
1 parent 3478553 commit 90779dc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/cli/action_extract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ bool ActionExtract::extract_file(

if (!ok) {
std::cerr << fmt::format(
"Could not convert image format '{}' -> '{}'!\n", NAMEOF_ENUM(file_->GetFormat()),
destIsFloat ? "RGBA32323232F" : "RGBA8888");
"Could not convert image format '{}' -> '{}': {}\n", NAMEOF_ENUM(file_->GetFormat()),
destIsFloat ? "RGBA32323232F" : "RGBA8888", util::get_last_vtflib_error());
return false;
}

Expand Down Expand Up @@ -249,7 +249,7 @@ bool ActionExtract::load_vtf(const std::filesystem::path& vtfFile) {
// Create new file & load it with vtflib
file_ = new VTFLib::CVTFFile();
if (!file_->Load(buf, numBytes, false)) {
std::cerr << fmt::format("Failed to load VTF '{}': {}\n", vtfFile.string(), vlGetLastError());
std::cerr << fmt::format("Failed to load VTF '{}': {}\n", vtfFile.string(), util::get_last_vtflib_error());
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/cli/action_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ int ActionInfo::exec(const OptionList& opts) {
// Load VTF with vtflib
file_ = new VTFLib::CVTFFile();
if (!file_->Load(buf, numBytes, false)) {
std::cerr << fmt::format(FMT_STRING("Failed to load VTF '{}': {}\n"), file, vlGetLastError());
std::cerr << fmt::format(FMT_STRING("Failed to load VTF '{}': {}\n"), file, util::get_last_vtflib_error());
return 1;
}

Expand Down
2 changes: 1 addition & 1 deletion src/cli/action_pack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ bool ActionPack::save_vtf(
initOpts.uiWidth = image->width();
initOpts.uiSlices = 1;
if (!file_->Init(initOpts)) {
std::cerr << fmt::format("Error while saving VTF: {}\n", vlGetLastError());
std::cerr << fmt::format("Error while saving VTF: {}\n", util::get_last_vtflib_error());
return false; // Cleanup done in cleanup()
}
file_->SetData(0, 0, 0, 0, image->data<vlByte>());
Expand Down

0 comments on commit 90779dc

Please sign in to comment.