Prise en charge propre des exceptions
This commit is contained in:
		
							parent
							
								
									586ba7ca10
								
							
						
					
					
						commit
						fbc43a400b
					
				
							
								
								
									
										13
									
								
								src/main.cpp
								
								
								
								
							
							
						
						
									
										13
									
								
								src/main.cpp
								
								
								
								
							|  | @ -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; | ||||
| } | ||||
|  |  | |||
|  | @ -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; | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue