Skip to content

Commit

Permalink
add 'try...catch' to std::filesystem::remove()
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosalie241 committed Jul 8, 2022
1 parent cded2ea commit dca8ab7
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion SporeModLoader/SporeModLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,18 @@ bool SporeModLoader::Initialize()
// remove log file if it exists
if (std::filesystem::exists(l_ModLoaderLogPath))
{
std::filesystem::remove(l_ModLoaderLogPath);
try
{
std::filesystem::remove(l_ModLoaderLogPath);
}
catch (...)
{
errorMessage = L"std::filesystem::remove(\"";
errorMessage += l_ModLoaderLogPath.wstring();
errorMessage += L"\") Failed!";
ShowErrorMessage(errorMessage);
throw std::exception();
}
}

for (const auto& path : { l_ModLoaderCoreLibsPath , l_ModLoaderModLibsPath })
Expand Down

0 comments on commit dca8ab7

Please sign in to comment.