mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-22 22:13:35 +02:00
Show error message if vcmi unable to access data directory instead of
silent crash
This commit is contained in:
parent
0e4be8c776
commit
2b7131cfea
@ -208,7 +208,14 @@ int main(int argc, char * argv[])
|
||||
logGlobal->info("The log file will be saved to %s", logPath);
|
||||
|
||||
// Init filesystem and settings
|
||||
preinitDLL(::console, false);
|
||||
try
|
||||
{
|
||||
preinitDLL(::console, false);
|
||||
}
|
||||
catch (const DataLoadingException & e)
|
||||
{
|
||||
handleFatalError(e.what(), true);
|
||||
}
|
||||
|
||||
Settings session = settings.write["session"];
|
||||
auto setSettingBool = [&](std::string key, std::string arg) {
|
||||
|
@ -10,6 +10,8 @@
|
||||
#include "StdInc.h"
|
||||
#include "CFileInputStream.h"
|
||||
|
||||
#include "../ExceptionsCommon.h"
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
CFileInputStream::CFileInputStream(const boost::filesystem::path & file, si64 start, si64 size)
|
||||
@ -18,7 +20,7 @@ CFileInputStream::CFileInputStream(const boost::filesystem::path & file, si64 st
|
||||
fileStream{file.c_str(), std::ios::in | std::ios::binary}
|
||||
{
|
||||
if (fileStream.fail())
|
||||
throw std::runtime_error("File " + file.string() + " isn't available.");
|
||||
throw DataLoadingException("Failed to open file '" + file.string() + "'. Reason: " + strerror(errno) );
|
||||
|
||||
if (dataSize == 0)
|
||||
{
|
||||
|
@ -12,14 +12,22 @@
|
||||
|
||||
#include "CFileInputStream.h"
|
||||
|
||||
#include "../ExceptionsCommon.h"
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
CFilesystemLoader::CFilesystemLoader(std::string _mountPoint, boost::filesystem::path baseDirectory, size_t depth, bool initial):
|
||||
baseDirectory(std::move(baseDirectory)),
|
||||
mountPoint(std::move(_mountPoint)),
|
||||
fileList(listFiles(mountPoint, depth, initial)),
|
||||
recursiveDepth(depth)
|
||||
{
|
||||
try {
|
||||
fileList = listFiles(mountPoint, depth, initial);
|
||||
}
|
||||
catch (const boost::filesystem::filesystem_error & e) {
|
||||
throw DataLoadingException("Failed to load content of '" + baseDirectory.string() + "'. Reason: " + e.what());
|
||||
}
|
||||
|
||||
logGlobal->trace("File system loaded, %d files found", fileList.size());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user