From c50769c8c57559a66d0308b0c20ff5f21cf1fa76 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Mon, 31 Jul 2023 15:21:10 +0400 Subject: [PATCH] Catch filesystem exceptions --- apps/niftest/niftest.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/apps/niftest/niftest.cpp b/apps/niftest/niftest.cpp index d08ccce4b8..06f2110e69 100644 --- a/apps/niftest/niftest.cpp +++ b/apps/niftest/niftest.cpp @@ -178,11 +178,20 @@ int main(int argc, char** argv) { vfs = std::make_unique(); for (const std::filesystem::path& path : archives) - if (auto archive = makeArchive(path)) - vfs->addArchive(std::move(archive)); - else - std::cerr << '"' << path << "\" is unsupported archive" << std::endl; - vfs->buildIndex(); + { + try + { + if (auto archive = makeArchive(path)) + vfs->addArchive(std::move(archive)); + else + std::cerr << '"' << path << "\" is unsupported archive" << std::endl; + vfs->buildIndex(); + } + catch (std::exception& e) + { + std::cerr << "ERROR, an exception has occurred: " << e.what() << std::endl; + } + } } // std::cout << "Reading Files" << std::endl;