1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-22 22:13:35 +02:00

Show message to player instead of crashing silently on extraction error

This commit is contained in:
Ivan Savenko 2024-06-26 11:18:59 +00:00
parent 2eeb6510c1
commit 5bc103f50e
2 changed files with 10 additions and 4 deletions

View File

@ -26,9 +26,15 @@ namespace
{
QString detectModArchive(QString path, QString modName, std::vector<std::string> & filesToExtract)
{
ZipArchive archive(qstringToPath(path));
filesToExtract = archive.listFiles();
try {
ZipArchive archive(qstringToPath(path));
filesToExtract = archive.listFiles();
}
catch (const std::runtime_error & e)
{
logGlobal->error("Failed to open zip archive. Reason: %s", e.what());
return "";
}
QString modDirName;

View File

@ -191,7 +191,7 @@ ZipArchive::ZipArchive(const boost::filesystem::path & from)
#endif
if (archive == nullptr)
throw std::runtime_error("Failed to open file '" + from.string() + "' - unable to list files!");
throw std::runtime_error("Failed to open file '" + from.string());
}
ZipArchive::~ZipArchive()