Properly handle exceptions when saving the game

Add message boxes when an exception occurs while loading or saving the game
deque
scrawl 11 years ago
parent 5df9ff8e2c
commit 8b33c087e0

@ -148,6 +148,8 @@ void MWState::StateManager::endGame()
}
void MWState::StateManager::saveGame (const std::string& description, const Slot *slot)
{
try
{
ESM::SavedGame profile;
@ -235,6 +237,18 @@ void MWState::StateManager::saveGame (const std::string& description, const Slot
Settings::Manager::setString ("character", "Saves",
slot->mPath.parent_path().filename().string());
}
catch (const std::exception& e)
{
std::stringstream error;
error << "Failed to save game: " << e.what();
std::cerr << error.str() << std::endl;
std::vector<std::string> buttons;
buttons.push_back("#{sOk}");
MWBase::Environment::get().getWindowManager()->messageBox(error.str(), buttons);
}
}
void MWState::StateManager::quickSave (std::string name)
{
@ -371,10 +385,17 @@ void MWState::StateManager::loadGame (const Character *character, const Slot *sl
}
catch (const std::exception& e)
{
std::cerr << "failed to load saved game: " << e.what() << std::endl;
std::stringstream error;
error << "Failed to load saved game: " << e.what();
std::cerr << error.str() << std::endl;
cleanup (true);
MWBase::Environment::get().getWindowManager()->pushGuiMode (MWGui::GM_MainMenu);
std::vector<std::string> buttons;
buttons.push_back("#{sOk}");
MWBase::Environment::get().getWindowManager()->messageBox(error.str(), buttons);
}
}

Loading…
Cancel
Save