From 90779dceb27c6b2e52b1190402af9da636d272a1 Mon Sep 17 00:00:00 2001 From: ENDERZOMBI102 Date: Sun, 21 Jan 2024 01:06:43 +0100 Subject: [PATCH] refactor: Use the same utility function to get vtflib errors --- src/cli/action_extract.cpp | 6 +++--- src/cli/action_info.cpp | 2 +- src/cli/action_pack.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cli/action_extract.cpp b/src/cli/action_extract.cpp index 23079bf..9df8055 100644 --- a/src/cli/action_extract.cpp +++ b/src/cli/action_extract.cpp @@ -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; } @@ -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; } diff --git a/src/cli/action_info.cpp b/src/cli/action_info.cpp index 403f1f3..b723926 100644 --- a/src/cli/action_info.cpp +++ b/src/cli/action_info.cpp @@ -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; } diff --git a/src/cli/action_pack.cpp b/src/cli/action_pack.cpp index 79617d1..09517c1 100644 --- a/src/cli/action_pack.cpp +++ b/src/cli/action_pack.cpp @@ -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());