Prise en charge propre des exceptions

This commit is contained in:
Mattéo Delabre 2016-03-24 20:11:25 +01:00
parent 586ba7ca10
commit fbc43a400b
2 changed files with 12 additions and 3 deletions

View File

@ -2,6 +2,7 @@
#include "block.hpp"
#include "engine.hpp"
#include "constants.hpp"
#include <cstdlib>
#include <iostream>
int main() {
@ -62,6 +63,14 @@ int main() {
engine.addObject(block21);
engine.addObject(block22);
engine.start();
return 0;
try {
engine.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;
}
return EXIT_SUCCESS;
}

View File

@ -41,7 +41,7 @@ sf::Texture& ResourceManager::getTexture(std::string name) {
// tente de charger la texture dans le chemin "CWD/res/name"
if (!texture.loadFromFile(path)) {
throw std::runtime_error("Impossible de charger l'image: " + name);
throw std::runtime_error("Impossible de charger l'image : " + name);
}
textures[name] = texture;