mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-08 00:39:47 +02:00
Show message to player instead of crashing silently on extraction error
This commit is contained in:
parent
2eeb6510c1
commit
5bc103f50e
@ -26,9 +26,15 @@ namespace
|
|||||||
{
|
{
|
||||||
QString detectModArchive(QString path, QString modName, std::vector<std::string> & filesToExtract)
|
QString detectModArchive(QString path, QString modName, std::vector<std::string> & filesToExtract)
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
ZipArchive archive(qstringToPath(path));
|
ZipArchive archive(qstringToPath(path));
|
||||||
|
|
||||||
filesToExtract = archive.listFiles();
|
filesToExtract = archive.listFiles();
|
||||||
|
}
|
||||||
|
catch (const std::runtime_error & e)
|
||||||
|
{
|
||||||
|
logGlobal->error("Failed to open zip archive. Reason: %s", e.what());
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
QString modDirName;
|
QString modDirName;
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ ZipArchive::ZipArchive(const boost::filesystem::path & from)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (archive == nullptr)
|
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()
|
ZipArchive::~ZipArchive()
|
||||||
|
Loading…
Reference in New Issue
Block a user