Capture des exceptions pour la lecture du fichier

This commit is contained in:
Mattéo Delabre 2016-04-02 15:06:21 +02:00
parent 25287bcc4b
commit a8e325cb20
1 changed files with 7 additions and 9 deletions

View File

@ -12,18 +12,16 @@ int main() {
Manager manager;
std::shared_ptr<Game> game = std::shared_ptr<Game>(new Game(manager));
// ouverture du niveau
std::ifstream file;
file.open("./levels/level1.dat", std::ios::binary | std::ios::in);
game->load(file);
file.close();
manager.setView(game);
try {
// ouverture du niveau
std::ifstream file;
file.open("./levels/level1.dat", std::ios::binary | std::ios::in);
game->load(file);
file.close();
manager.setView(game);
manager.start();
} catch (const std::exception& exception) {
std::cerr << std::endl;
std::cerr << "Le programme a quitté après une erreur d'exécution." << std::endl;
std::cerr << exception.what() << std::endl;
return EXIT_FAILURE;