Made Exception more verbose

This commit is contained in:
Robert 2020-05-18 20:20:00 +02:00
parent 1450875965
commit 5709c595c3
2 changed files with 7 additions and 5 deletions

View file

@ -6,6 +6,7 @@
*/ */
#pragma once #pragma once
#include <exception> #include <exception>
#include <string>
namespace sdlu namespace sdlu
{ {
@ -13,7 +14,7 @@ namespace sdlu
virtual public std::exception virtual public std::exception
{ {
public: public:
ObjectCreationException(const char* description) : ObjectCreationException(std::string description) :
m_pDescription(description) m_pDescription(description)
{ {
// Empty // Empty
@ -21,10 +22,10 @@ namespace sdlu
virtual const char* what() const throw() virtual const char* what() const throw()
{ {
return m_pDescription; return m_pDescription.c_str();
} }
private: private:
const char* m_pDescription; std::string m_pDescription;
}; };
} }

View file

@ -36,12 +36,13 @@ namespace sdlu
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
dimension.x, dimension.y, dimension.x, dimension.y,
windowFlags); windowFlags);
THROW_IF(IS_NULLPTR(m_pWindow), THROW_IF(IS_NULLPTR(m_pWindow),
ObjectCreationException("Failed to create SDL_Window.")); ObjectCreationException("Failed to create SDL_Window. \nSDL_GetError(): " + std::string(SDL_GetError())));
m_pRenderer = SDL_CreateRenderer(m_pWindow, -1, rendererFlags); m_pRenderer = SDL_CreateRenderer(m_pWindow, -1, rendererFlags);
THROW_IF(IS_NULLPTR(m_pRenderer), THROW_IF(IS_NULLPTR(m_pRenderer),
ObjectCreationException("Failed to create SDL_Renderer.")); ObjectCreationException("Failed to create SDL_Renderer. \nSDL_GetError(): " + std::string(SDL_GetError())));
OnCreate(); OnCreate();
} }