From 5709c595c3af8ce1aa8994ea01ad73bc4b4afb95 Mon Sep 17 00:00:00 2001 From: Robert Date: Mon, 18 May 2020 20:20:00 +0200 Subject: [PATCH] Made Exception more verbose --- SDLU/exceptions/ObjectCreationException.hpp | 7 ++++--- SDLU/graphics/RenderWindow.cpp | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/SDLU/exceptions/ObjectCreationException.hpp b/SDLU/exceptions/ObjectCreationException.hpp index d409ba5..0aae211 100644 --- a/SDLU/exceptions/ObjectCreationException.hpp +++ b/SDLU/exceptions/ObjectCreationException.hpp @@ -6,6 +6,7 @@ */ #pragma once #include +#include namespace sdlu { @@ -13,7 +14,7 @@ namespace sdlu virtual public std::exception { public: - ObjectCreationException(const char* description) : + ObjectCreationException(std::string description) : m_pDescription(description) { // Empty @@ -21,10 +22,10 @@ namespace sdlu virtual const char* what() const throw() { - return m_pDescription; + return m_pDescription.c_str(); } private: - const char* m_pDescription; + std::string m_pDescription; }; } \ No newline at end of file diff --git a/SDLU/graphics/RenderWindow.cpp b/SDLU/graphics/RenderWindow.cpp index 9143968..eddedb6 100644 --- a/SDLU/graphics/RenderWindow.cpp +++ b/SDLU/graphics/RenderWindow.cpp @@ -36,12 +36,13 @@ namespace sdlu SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, dimension.x, dimension.y, windowFlags); + 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); 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(); }