0
0
mirror of https://github.com/Nimac0/SDL_Minigame synced 2026-01-13 14:53:41 +00:00

added error throwing for texture load

makes runtime error more descriptive
This commit is contained in:
Benedikt Galbavy 2024-01-23 22:33:08 +01:00
parent 7bc17eb8b9
commit 06042583f8

View File

@ -1,5 +1,7 @@
#include "TextureManager.h"
#include <cstdio>
#include <stdexcept>
#include <string>
#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;
}