From 06042583f8a1f23c001a7bc9b427830344061039 Mon Sep 17 00:00:00 2001 From: Benedikt Galbavy Date: Tue, 23 Jan 2024 22:33:08 +0100 Subject: [PATCH] added error throwing for texture load makes runtime error more descriptive --- src/TextureManager.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/TextureManager.cpp b/src/TextureManager.cpp index ae597e0..fa9ee07 100644 --- a/src/TextureManager.cpp +++ b/src/TextureManager.cpp @@ -1,5 +1,7 @@ #include "TextureManager.h" #include +#include +#include #include "Game.h" SDL_Texture* TextureManager::loadTexture(const char* fileName) @@ -9,6 +11,7 @@ SDL_Texture* TextureManager::loadTexture(const char* fileName) return it->second; } auto texture = IMG_LoadTexture(Game::renderer, fileName); + if (texture == NULL) throw std::runtime_error(std::string("Couldn't load texture '") + fileName + "'"); this->texture_cache.emplace(fileName, texture); return texture; }