From 689f57b864ea081d5c2df43d75adfd0640424038 Mon Sep 17 00:00:00 2001 From: Dmitry Marakasov Date: Mon, 19 Jan 2015 01:41:37 +0300 Subject: [PATCH] Exception rework Now it explicitely stores name of SDL function which caused an error and generates complete user-readable error message which contains both function name and SDL error message. Users can now handle SDL2pp exceptions along with all others in `catch (std::exception&)' and get complete error info. While here, fixed incorrect function names in some throw's --- README.md | 9 ++++-- SDL2pp/AudioDevice.cc | 6 ++-- SDL2pp/Exception.cc | 17 ++++++++---- SDL2pp/Exception.hh | 19 +++++++++---- SDL2pp/Font.cc | 40 +++++++++++++-------------- SDL2pp/RWops.cc | 10 +++---- SDL2pp/RWops.hh | 2 +- SDL2pp/Renderer.cc | 60 ++++++++++++++++++++-------------------- SDL2pp/SDL.cc | 6 ++-- SDL2pp/SDLImage.cc | 6 ++-- SDL2pp/SDLTTF.cc | 4 +-- SDL2pp/Surface.cc | 40 +++++++++++++-------------- SDL2pp/SurfaceLock.cc | 4 +-- SDL2pp/Texture.cc | 34 +++++++++++------------ SDL2pp/TextureLock.cc | 4 +-- SDL2pp/Wav.cc | 6 ++-- SDL2pp/Window.cc | 6 ++-- examples/audio_sine.cc | 5 +--- examples/audio_wav.cc | 5 +--- examples/image.cc | 5 +--- examples/lines.cc | 5 +--- examples/rendertarget.cc | 3 -- examples/sprites.cc | 5 +--- examples/ttf.cc | 7 +---- 24 files changed, 152 insertions(+), 156 deletions(-) diff --git a/README.md b/README.md index cc4026a..9ce7682 100644 --- a/README.md +++ b/README.md @@ -43,9 +43,12 @@ This library provides C++11 bindings/wrapper for SDL2 and satellite libraries. // All SDL objects are released at this point or if an error occurs } catch (SDL2pp::Exception& e) { - // Exception stores SDL_GetError() result - std::cerr << "Exception: " << e.what() << std::endl; - std::cerr << "SDL Error: " << e.GetSDLError() << std::endl; + // Exception stores SDL_GetError() result and name of function which failed + std::cerr << "Error in: " << e.GetSDLFunction() << std::endl; + std::cerr << " Reason: " << e.GetSDLError() << std::endl; + } catch (std::exception& e) { + // This also works (e.g. "SDL_Init failed: No available video device") + std::cerr << e.what() << std::endl; } ## Features ## diff --git a/SDL2pp/AudioDevice.cc b/SDL2pp/AudioDevice.cc index 6d2bba0..5d76ef3 100644 --- a/SDL2pp/AudioDevice.cc +++ b/SDL2pp/AudioDevice.cc @@ -40,7 +40,7 @@ AudioDevice::AudioDevice(const Optional& device, bool iscapture, co SDL_AudioSpec obtained; if ((device_id_ = SDL_OpenAudioDevice(device ? device->c_str() : nullptr, iscapture ? 1 : 0, &spec_with_callback, &obtained, 0)) == 0) - throw Exception("SDL_OpenAudioDevice failed"); + throw Exception("SDL_OpenAudioDevice"); callback_ = std::move(callback); } @@ -54,7 +54,7 @@ AudioDevice::AudioDevice(const Optional& device, bool iscapture, Au SDL_AudioSpec obtained; if ((device_id_ = SDL_OpenAudioDevice(device ? device->c_str() : nullptr, iscapture ? 1 : 0, &spec_with_callback, &obtained, allowed_changes)) == 0) - throw Exception("SDL_OpenAudioDevice failed"); + throw Exception("SDL_OpenAudioDevice"); spec.MergeChanges(obtained); @@ -113,7 +113,7 @@ AudioDevice::LockHandle AudioDevice::Lock() { #ifdef SDL2PP_WITH_2_0_4 AudioDevice& AudioDevice::QueueAudio(const void* data, Uint32 len) { if (SDL_QueueAudio(device_id_, data, len) == 0) - throw Exception("SDL_QueueAudio failed"); + throw Exception("SDL_QueueAudio"); return *this; } diff --git a/SDL2pp/Exception.cc b/SDL2pp/Exception.cc index 463415c..f41e420 100644 --- a/SDL2pp/Exception.cc +++ b/SDL2pp/Exception.cc @@ -1,6 +1,6 @@ /* libSDL2pp - C++11 bindings/wrapper for SDL2 - Copyright (C) 2013-2014 Dmitry Marakasov + Copyright (C) 2013-2015 Dmitry Marakasov This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -25,18 +25,25 @@ namespace SDL2pp { -Exception::Exception(const char* what) : what_(what), sdl_error_(SDL_GetError()) { +Exception::Exception(const char* function) + : sdl_function_(function), + sdl_error_(SDL_GetError()), + what_(sdl_function_ + " failed: " + sdl_error_) { } Exception::~Exception() noexcept { } const char* Exception::what() const noexcept { - return what_; + return what_.c_str(); } -const char* Exception::GetSDLError() const noexcept { - return sdl_error_.c_str(); +std::string Exception::GetSDLFunction() const { + return sdl_function_; +} + +std::string Exception::GetSDLError() const { + return sdl_error_; } } // namespace SDL2pp diff --git a/SDL2pp/Exception.hh b/SDL2pp/Exception.hh index 48b731e..5c66468 100644 --- a/SDL2pp/Exception.hh +++ b/SDL2pp/Exception.hh @@ -68,17 +68,18 @@ namespace SDL2pp { //////////////////////////////////////////////////////////// class Exception : public std::exception { private: - const char* what_; ///< User-specified message - std::string sdl_error_; ///< SDL error string + std::string sdl_function_; ///< SDL function which caused an error + std::string sdl_error_; ///< SDL error string + std::string what_; ///< User-readable message public: //////////////////////////////////////////////////////////// /// \brief Construct exception, storing result of SDL_GetError() /// - /// \param[in] what User-specified explanatory string + /// \param[in] function Name of SDL function which generated an error /// //////////////////////////////////////////////////////////// - Exception(const char* what = ""); + Exception(const char* function); //////////////////////////////////////////////////////////// /// \brief Destructor @@ -94,6 +95,14 @@ public: //////////////////////////////////////////////////////////// const char* what() const noexcept; + //////////////////////////////////////////////////////////// + /// \brief Get name of SDL function which caused an error + /// + /// \returns Name of function which caused an error + /// + //////////////////////////////////////////////////////////// + std::string GetSDLFunction() const; + //////////////////////////////////////////////////////////// /// \brief Get SDL2 error text /// @@ -102,7 +111,7 @@ public: /// \see http://wiki.libsdl.org/SDL_GetError /// //////////////////////////////////////////////////////////// - const char* GetSDLError() const noexcept; + std::string GetSDLError() const; }; } diff --git a/SDL2pp/Font.cc b/SDL2pp/Font.cc index 86b7ec8..1882b15 100644 --- a/SDL2pp/Font.cc +++ b/SDL2pp/Font.cc @@ -33,12 +33,12 @@ Font::Font(TTF_Font* font) { Font::Font(const std::string& file, int ptsize, long index) { if ((font_ = TTF_OpenFontIndex(file.c_str(), ptsize, index)) == nullptr) - throw Exception("TTF_OpenFontIndex failed"); + throw Exception("TTF_OpenFontIndex"); } Font::Font(RWops& rwops, int ptsize, long index) { if ((font_ = TTF_OpenFontIndexRW(rwops.Get(), 0, ptsize, index)) == nullptr) - throw Exception("TTF_OpenFontIndexRW failed"); + throw Exception("TTF_OpenFontIndexRW"); } Font::~Font() { @@ -140,125 +140,125 @@ Optional Font::GetStyleName() const { void Font::GetGlyphMetrics(Uint16 ch, int& minx, int& maxx, int& miny, int& maxy, int& advance) const { if (TTF_GlyphMetrics(font_, ch, &minx, &maxx, &miny, &maxy, &advance) != 0) - throw Exception("TTF_GlyphMetrics failed"); + throw Exception("TTF_GlyphMetrics"); } Rect Font::GetGlyphRect(Uint16 ch) const { int minx, maxx, miny, maxy; if (TTF_GlyphMetrics(font_, ch, &minx, &maxx, &miny, &maxy, nullptr) != 0) - throw Exception("TTF_GlyphMetrics failed"); + throw Exception("TTF_GlyphMetrics"); return Rect(minx, miny, maxx - minx + 1, maxy - miny + 1); } int Font::GetGlyphAdvance(Uint16 ch) const { int advance; if (TTF_GlyphMetrics(font_, ch, nullptr, nullptr, nullptr, nullptr, &advance) != 0) - throw Exception("TTF_GlyphMetrics failed"); + throw Exception("TTF_GlyphMetrics"); return advance; } Point Font::GetSizeText(const std::string& text) const { int w, h; if (TTF_SizeText(font_, text.c_str(), &w, &h) != 0) - throw Exception("TTF_SizeText failed"); + throw Exception("TTF_SizeText"); return Point(w, h); } Point Font::GetSizeUTF8(const std::string& text) const { int w, h; if (TTF_SizeUTF8(font_, text.c_str(), &w, &h) != 0) - throw Exception("TTF_SizeUTF8 failed"); + throw Exception("TTF_SizeUTF8"); return Point(w, h); } Point Font::GetSizeUNICODE(const Uint16* text) const { int w, h; if (TTF_SizeUNICODE(font_, text, &w, &h) != 0) - throw Exception("TTF_SizeUNICODE failed"); + throw Exception("TTF_SizeUNICODE"); return Point(w, h); } Surface Font::RenderText_Solid(const std::string& text, SDL_Color fg) { SDL_Surface* surface = TTF_RenderText_Solid(font_, text.c_str(), fg); if (surface == nullptr) - throw Exception("TTF_RenderText_Solid failed"); + throw Exception("TTF_RenderText_Solid"); return Surface(surface); } Surface Font::RenderUTF8_Solid(const std::string& text, SDL_Color fg) { SDL_Surface* surface = TTF_RenderUTF8_Solid(font_, text.c_str(), fg); if (surface == nullptr) - throw Exception("TTF_RenderUTF8_Solid failed"); + throw Exception("TTF_RenderUTF8_Solid"); return Surface(surface); } Surface Font::RenderUNICODE_Solid(const Uint16* text, SDL_Color fg) { SDL_Surface* surface = TTF_RenderUNICODE_Solid(font_, text, fg); if (surface == nullptr) - throw Exception("TTF_RenderUNICODE_Solid failed"); + throw Exception("TTF_RenderUNICODE_Solid"); return Surface(surface); } Surface Font::RenderGlyph_Solid(Uint16 ch, SDL_Color fg) { SDL_Surface* surface = TTF_RenderGlyph_Solid(font_, ch, fg); if (surface == nullptr) - throw Exception("TTF_RenderGlyph_Solid failed"); + throw Exception("TTF_RenderGlyph_Solid"); return Surface(surface); } Surface Font::RenderText_Shaded(const std::string& text, SDL_Color fg, SDL_Color bg) { SDL_Surface* surface = TTF_RenderText_Shaded(font_, text.c_str(), fg, bg); if (surface == nullptr) - throw Exception("TTF_RenderText_Shaded failed"); + throw Exception("TTF_RenderText_Shaded"); return Surface(surface); } Surface Font::RenderUTF8_Shaded(const std::string& text, SDL_Color fg, SDL_Color bg) { SDL_Surface* surface = TTF_RenderUTF8_Shaded(font_, text.c_str(), fg, bg); if (surface == nullptr) - throw Exception("TTF_RenderUTF8_Shaded failed"); + throw Exception("TTF_RenderUTF8_Shaded"); return Surface(surface); } Surface Font::RenderUNICODE_Shaded(const Uint16* text, SDL_Color fg, SDL_Color bg) { SDL_Surface* surface = TTF_RenderUNICODE_Shaded(font_, text, fg, bg); if (surface == nullptr) - throw Exception("TTF_RenderUNICODE_Shaded failed"); + throw Exception("TTF_RenderUNICODE_Shaded"); return Surface(surface); } Surface Font::RenderGlyph_Shaded(Uint16 ch, SDL_Color fg, SDL_Color bg) { SDL_Surface* surface = TTF_RenderGlyph_Shaded(font_, ch, fg, bg); if (surface == nullptr) - throw Exception("TTF_RenderGlyph_Shaded failed"); + throw Exception("TTF_RenderGlyph_Shaded"); return Surface(surface); } Surface Font::RenderText_Blended(const std::string& text, SDL_Color fg) { SDL_Surface* surface = TTF_RenderText_Blended(font_, text.c_str(), fg); if (surface == nullptr) - throw Exception("TTF_RenderText_Blended failed"); + throw Exception("TTF_RenderText_Blended"); return Surface(surface); } Surface Font::RenderUTF8_Blended(const std::string& text, SDL_Color fg) { SDL_Surface* surface = TTF_RenderUTF8_Blended(font_, text.c_str(), fg); if (surface == nullptr) - throw Exception("TTF_RenderUTF8_Blended failed"); + throw Exception("TTF_RenderUTF8_Blended"); return Surface(surface); } Surface Font::RenderUNICODE_Blended(const Uint16* text, SDL_Color fg) { SDL_Surface* surface = TTF_RenderUNICODE_Blended(font_, text, fg); if (surface == nullptr) - throw Exception("TTF_RenderUNICODE_Blended failed"); + throw Exception("TTF_RenderUNICODE_Blended"); return Surface(surface); } Surface Font::RenderGlyph_Blended(Uint16 ch, SDL_Color fg) { SDL_Surface* surface = TTF_RenderGlyph_Blended(font_, ch, fg); if (surface == nullptr) - throw Exception("TTF_RenderGlyph_Blended failed"); + throw Exception("TTF_RenderGlyph_Blended"); return Surface(surface); } diff --git a/SDL2pp/RWops.cc b/SDL2pp/RWops.cc index 93128a2..254680f 100644 --- a/SDL2pp/RWops.cc +++ b/SDL2pp/RWops.cc @@ -114,25 +114,25 @@ RWops RWops::CheckedCreateStandardRWops(SDL_RWops* sdl_rwops, const char* errmsg } RWops RWops::FromFP(FILE* file, bool autoclose) { - return CheckedCreateStandardRWops(SDL_RWFromFP(file, autoclose ? SDL_TRUE : SDL_FALSE), "SDL_RWFromFP failed"); + return CheckedCreateStandardRWops(SDL_RWFromFP(file, autoclose ? SDL_TRUE : SDL_FALSE), "SDL_RWFromFP"); } RWops RWops::FromConstMem(const void* mem, int size) { - return CheckedCreateStandardRWops(SDL_RWFromConstMem(mem, size), "SDL_RWFromConstMem failed"); + return CheckedCreateStandardRWops(SDL_RWFromConstMem(mem, size), "SDL_RWFromConstMem"); } RWops RWops::FromMem(void* mem, int size) { - return CheckedCreateStandardRWops(SDL_RWFromMem(mem, size), "SDL_RWFromMem failed"); + return CheckedCreateStandardRWops(SDL_RWFromMem(mem, size), "SDL_RWFromMem"); } RWops RWops::FromFile(const std::string& file, const std::string& mode) { - return CheckedCreateStandardRWops(SDL_RWFromFile(file.c_str(), mode.c_str()), "SDL_RWFromFile failed"); + return CheckedCreateStandardRWops(SDL_RWFromFile(file.c_str(), mode.c_str()), "SDL_RWFromFile"); } RWops::RWops(SDL_RWops* rwops) { rwops_ = SDL_AllocRW(); if (rwops_ == nullptr) - throw Exception("SDL_AllocRW failed"); + throw Exception("SDL_AllocRW"); rwops_->seek = StdSeekFuncWrapper; rwops_->read = StdReadFuncWrapper; diff --git a/SDL2pp/RWops.hh b/SDL2pp/RWops.hh index 6210378..6fc9b98 100644 --- a/SDL2pp/RWops.hh +++ b/SDL2pp/RWops.hh @@ -269,7 +269,7 @@ public: RWops(C&& custom_rwops) { rwops_ = SDL_AllocRW(); if (rwops_ == nullptr) - throw Exception("SDL_AllocRW failed"); + throw Exception("SDL_AllocRW"); rwops_->seek = CustomSeekFuncWrapper; rwops_->read = CustomReadFuncWrapper; diff --git a/SDL2pp/Renderer.cc b/SDL2pp/Renderer.cc index 3ae0e96..cbccf8f 100644 --- a/SDL2pp/Renderer.cc +++ b/SDL2pp/Renderer.cc @@ -35,7 +35,7 @@ Renderer::Renderer(SDL_Renderer* renderer) : renderer_(renderer) { Renderer::Renderer(Window& window, int index, Uint32 flags) { if ((renderer_ = SDL_CreateRenderer(window.Get(), index, flags)) == nullptr) - throw Exception("SDL_CreateRenderer failed"); + throw Exception("SDL_CreateRenderer"); } Renderer::~Renderer() { @@ -68,59 +68,59 @@ Renderer& Renderer::Present() { Renderer& Renderer::Clear() { if (SDL_RenderClear(renderer_) != 0) - throw Exception("SDL_RenderClear failed"); + throw Exception("SDL_RenderClear"); return *this; } void Renderer::GetInfo(SDL_RendererInfo* info) { if (SDL_GetRendererInfo(renderer_, info) != 0) - throw Exception("SDL_GetRendererInfo failed"); + throw Exception("SDL_GetRendererInfo"); } void Renderer::GetInfo(SDL_RendererInfo& info) { if (SDL_GetRendererInfo(renderer_, &info) != 0) - throw Exception("SDL_GetRendererInfo failed"); + throw Exception("SDL_GetRendererInfo"); } Renderer& Renderer::Copy(Texture& texture, const Optional& srcrect, const Optional& dstrect) { if (SDL_RenderCopy(renderer_, texture.Get(), srcrect ? &*srcrect : nullptr, dstrect ? &*dstrect : nullptr) != 0) - throw Exception("SDL_RenderCopy failed"); + throw Exception("SDL_RenderCopy"); return *this; } Renderer& Renderer::Copy(Texture& texture, const Optional& srcrect, const Optional& dstrect, double angle, const Optional& center, int flip) { if (SDL_RenderCopyEx(renderer_, texture.Get(), srcrect ? &*srcrect : nullptr, dstrect ? &*dstrect : nullptr, angle, center ? &*center : nullptr, static_cast(flip)) != 0) - throw Exception("SDL_RenderCopyEx failed"); + throw Exception("SDL_RenderCopyEx"); return *this; } Renderer& Renderer::SetDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a) { if (SDL_SetRenderDrawColor(renderer_, r, g, b, a) != 0) - throw Exception("SDL_SetRenderDrawColor failed"); + throw Exception("SDL_SetRenderDrawColor"); return *this; } Renderer& Renderer::SetTarget() { if (SDL_SetRenderTarget(renderer_, nullptr) != 0) - throw Exception("SDL_SetRenderTarget failed"); + throw Exception("SDL_SetRenderTarget"); return *this; } Renderer& Renderer::SetTarget(Texture& texture) { if (SDL_SetRenderTarget(renderer_, texture.Get()) != 0) - throw Exception("SDL_SetRenderTarget failed"); + throw Exception("SDL_SetRenderTarget"); return *this; } Renderer& Renderer::SetDrawBlendMode(SDL_BlendMode blendMode) { if (SDL_SetRenderDrawBlendMode(renderer_, blendMode) != 0) - throw Exception("SDL_SetRenderDrawBlendMode failed"); + throw Exception("SDL_SetRenderDrawBlendMode"); return *this; } Renderer& Renderer::DrawPoint(int x, int y) { if (SDL_RenderDrawPoint(renderer_, x, y) != 0) - throw Exception("SDL_RenderDrawPoint failed"); + throw Exception("SDL_RenderDrawPoint"); return *this; } @@ -136,14 +136,14 @@ Renderer& Renderer::DrawPoints(const Point* points, int count) { sdl_points.emplace_back(*p); if (SDL_RenderDrawPoints(renderer_, sdl_points.data(), sdl_points.size()) != 0) - throw Exception("SDL_RenderDrawPoints failed"); + throw Exception("SDL_RenderDrawPoints"); return *this; } Renderer& Renderer::DrawLine(int x1, int y1, int x2, int y2) { if (SDL_RenderDrawLine(renderer_, x1, y1, x2, y2) != 0) - throw Exception("SDL_RenderDrawLine failed"); + throw Exception("SDL_RenderDrawLine"); return *this; } @@ -159,7 +159,7 @@ Renderer& Renderer::DrawLines(const Point* points, int count) { sdl_points.emplace_back(*p); if (SDL_RenderDrawLines(renderer_, sdl_points.data(), sdl_points.size()) != 0) - throw Exception("SDL_RenderDrawLines failed"); + throw Exception("SDL_RenderDrawLines"); return *this; } @@ -167,7 +167,7 @@ Renderer& Renderer::DrawLines(const Point* points, int count) { Renderer& Renderer::DrawRect(int x1, int y1, int x2, int y2) { SDL_Rect rect = {x1, y1, x2 - x1 + 1, y2 - y1 + 1}; if (SDL_RenderDrawRect(renderer_, &rect) != 0) - throw Exception("SDL_RenderDrawRect failed"); + throw Exception("SDL_RenderDrawRect"); return *this; } @@ -178,7 +178,7 @@ Renderer& Renderer::DrawRect(const Point& p1, const Point& p2) { Renderer& Renderer::DrawRect(const Rect& r) { if (SDL_RenderDrawRect(renderer_, &r) != 0) - throw Exception("SDL_RenderDrawRect failed"); + throw Exception("SDL_RenderDrawRect"); return *this; } @@ -189,7 +189,7 @@ Renderer& Renderer::DrawRects(const Rect* rects, int count) { sdl_rects.emplace_back(*r); if (SDL_RenderDrawRects(renderer_, sdl_rects.data(), sdl_rects.size()) != 0) - throw Exception("SDL_RenderDrawRects failed"); + throw Exception("SDL_RenderDrawRects"); return *this; } @@ -197,7 +197,7 @@ Renderer& Renderer::DrawRects(const Rect* rects, int count) { Renderer& Renderer::FillRect(int x1, int y1, int x2, int y2) { SDL_Rect rect = {x1, y1, x2 - x1 + 1, y2 - y1 + 1}; if (SDL_RenderFillRect(renderer_, &rect) != 0) - throw Exception("SDL_RenderFillRect failed"); + throw Exception("SDL_RenderFillRect"); return *this; } @@ -208,7 +208,7 @@ Renderer& Renderer::FillRect(const Point& p1, const Point& p2) { Renderer& Renderer::FillRect(const Rect& r) { if (SDL_RenderFillRect(renderer_, &r) != 0) - throw Exception("SDL_RenderFillRect failed"); + throw Exception("SDL_RenderFillRect"); return *this; } @@ -219,37 +219,37 @@ Renderer& Renderer::FillRects(const Rect* rects, int count) { sdl_rects.emplace_back(*r); if (SDL_RenderFillRects(renderer_, sdl_rects.data(), sdl_rects.size()) != 0) - throw Exception("SDL_RenderFillRects failed"); + throw Exception("SDL_RenderFillRects"); return *this; } void Renderer::ReadPixels(const Optional& rect, Uint32 format, void* pixels, int pitch) { if (SDL_RenderReadPixels(renderer_, rect ? &*rect : nullptr, format, pixels, pitch) != 0) - throw Exception("SDL_RenderReadPixels failed"); + throw Exception("SDL_RenderReadPixels"); } Renderer& Renderer::SetClipRect(const Optional& rect) { if (SDL_RenderSetClipRect(renderer_, rect ? &*rect : nullptr) != 0) - throw Exception("SDL_RenderSetClipRect failed"); + throw Exception("SDL_RenderSetClipRect"); return *this; } Renderer& Renderer::SetLogicalSize(int w, int h) { if (SDL_RenderSetLogicalSize(renderer_, w, h) != 0) - throw Exception("SDL_RenderSetLogicalSize failed"); + throw Exception("SDL_RenderSetLogicalSize"); return *this; } Renderer& Renderer::SetScale(float scaleX, float scaleY) { if (SDL_RenderSetScale(renderer_, scaleX, scaleY) != 0) - throw Exception("SDL_RenderSetScale failed"); + throw Exception("SDL_RenderSetScale"); return *this; } Renderer& Renderer::SetViewport(const Optional& rect) { if (SDL_RenderSetViewport(renderer_, rect ? &*rect : nullptr) != 0) - throw Exception("SDL_RenderSetViewport failed"); + throw Exception("SDL_RenderSetViewport"); return *this; } @@ -306,33 +306,33 @@ Rect Renderer::GetViewport() const { SDL_BlendMode Renderer::GetDrawBlendMode() const { SDL_BlendMode mode; if (SDL_GetRenderDrawBlendMode(renderer_, &mode) != 0) - throw Exception("SDL_GetRenderDrawBlendMode failed"); + throw Exception("SDL_GetRenderDrawBlendMode"); return mode; } void Renderer::GetDrawColor(Uint8& r, Uint8& g, Uint8& b, Uint8& a) const { if (SDL_GetRenderDrawColor(renderer_, &r, &g, &b, &a) != 0) - throw Exception("SDL_GetRenderDrawColor failed"); + throw Exception("SDL_GetRenderDrawColor"); } Point Renderer::GetOutputSize() const { int w, h; if (SDL_GetRendererOutputSize(renderer_, &w, &h) != 0) - throw Exception("SDL_GetRendererOutputSize failed"); + throw Exception("SDL_GetRendererOutputSize"); return Point(w, h); } int Renderer::GetOutputWidth() const { int w; if (SDL_GetRendererOutputSize(renderer_, &w, nullptr) != 0) - throw Exception("SDL_GetRendererOutputSize failed"); + throw Exception("SDL_GetRendererOutputSize"); return w; } int Renderer::GetOutputHeight() const { int h; if (SDL_GetRendererOutputSize(renderer_, nullptr, &h) != 0) - throw Exception("SDL_GetRendererOutputSize failed"); + throw Exception("SDL_GetRendererOutputSize"); return h; } diff --git a/SDL2pp/SDL.cc b/SDL2pp/SDL.cc index 9215e57..fa1b620 100644 --- a/SDL2pp/SDL.cc +++ b/SDL2pp/SDL.cc @@ -1,6 +1,6 @@ /* libSDL2pp - C++11 bindings/wrapper for SDL2 - Copyright (C) 2013-2014 Dmitry Marakasov + Copyright (C) 2013-2015 Dmitry Marakasov This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -28,7 +28,7 @@ namespace SDL2pp { SDL::SDL(Uint32 flags) { if (SDL_Init(flags) != 0) - throw Exception("SDL_Init failed"); + throw Exception("SDL_Init"); } SDL::~SDL() { @@ -41,7 +41,7 @@ Uint32 WasInit(Uint32 flags) { void InitSubsystem(Uint32 flags) { if (SDL_InitSubSystem(flags) != 0) - throw Exception("SDL_InitSubsystem failed"); + throw Exception("SDL_InitSubsystem"); } void QuitSubSystem(Uint32 flags) { diff --git a/SDL2pp/SDLImage.cc b/SDL2pp/SDLImage.cc index f2e9c66..6da2d56 100644 --- a/SDL2pp/SDLImage.cc +++ b/SDL2pp/SDLImage.cc @@ -1,6 +1,6 @@ /* libSDL2pp - C++11 bindings/wrapper for SDL2 - Copyright (C) 2014 Dmitry Marakasov + Copyright (C) 2014-2015 Dmitry Marakasov This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -28,7 +28,7 @@ namespace SDL2pp { SDLImage::SDLImage(int flags) { if ((IMG_Init(flags) & flags) != flags) - throw Exception("IMG_Init failed"); + throw Exception("IMG_Init"); } SDLImage::~SDLImage() { @@ -38,7 +38,7 @@ SDLImage::~SDLImage() { int SDLImage::InitMore(int flags) { int ret; if (((ret = IMG_Init(flags)) & flags) != flags) - throw Exception("IMG_Init failed"); + throw Exception("IMG_Init"); return ret; } diff --git a/SDL2pp/SDLTTF.cc b/SDL2pp/SDLTTF.cc index ad5119c..0eb187d 100644 --- a/SDL2pp/SDLTTF.cc +++ b/SDL2pp/SDLTTF.cc @@ -1,6 +1,6 @@ /* libSDL2pp - C++11 bindings/wrapper for SDL2 - Copyright (C) 2014 Dmitry Marakasov + Copyright (C) 2014-2015 Dmitry Marakasov This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -28,7 +28,7 @@ namespace SDL2pp { SDLTTF::SDLTTF() { if (TTF_Init() != 0) - throw Exception("TTF_Init failed"); + throw Exception("TTF_Init"); } SDLTTF::~SDLTTF() { diff --git a/SDL2pp/Surface.cc b/SDL2pp/Surface.cc index f9fca5f..3178ba0 100644 --- a/SDL2pp/Surface.cc +++ b/SDL2pp/Surface.cc @@ -41,23 +41,23 @@ Surface::Surface(SDL_Surface* surface) : surface_(surface) { Surface::Surface(Uint32 flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) { if ((surface_ = SDL_CreateRGBSurface(flags, width, height, depth, Rmask, Gmask, Bmask, Amask)) == nullptr) - throw Exception("SDL_CreateRGBSurface failed"); + throw Exception("SDL_CreateRGBSurface"); } Surface::Surface(void* pixels, int width, int height, int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) { if ((surface_ = SDL_CreateRGBSurfaceFrom(pixels, width, height, depth, pitch, Rmask, Gmask, Bmask, Amask)) == nullptr) - throw Exception("SDL_CreateRGBSurfaceFrom failed"); + throw Exception("SDL_CreateRGBSurfaceFrom"); } #ifdef SDL2PP_WITH_IMAGE Surface::Surface(RWops& rwops) { if ((surface_ = IMG_Load_RW(rwops.Get(), 0)) == nullptr) - throw Exception("IMG_Load_RW failed"); + throw Exception("IMG_Load_RW"); } Surface::Surface(const std::string& path) { if ((surface_ = IMG_Load(path.c_str())) == nullptr) - throw Exception("IMG_Load failed"); + throw Exception("IMG_Load"); } #endif @@ -87,21 +87,21 @@ SDL_Surface* Surface::Get() const { Surface Surface::Convert(const SDL_PixelFormat& format) { SDL_Surface* surface = SDL_ConvertSurface(surface_, &format, 0); if (surface == nullptr) - throw Exception("SDL_ConvertPixels failed"); + throw Exception("SDL_ConvertSurface"); return surface; } Surface Surface::Convert(Uint32 pixel_format) { SDL_Surface* surface = SDL_ConvertSurfaceFormat(surface_, pixel_format, 0); if (surface == nullptr) - throw Exception("SDL_ConvertPixels failed"); + throw Exception("SDL_ConvertSurfaceFormat"); return surface; } void Surface::Blit(const Optional& srcrect, Surface& dst, const Rect& dstrect) { SDL_Rect tmpdstrect = dstrect; // 4th argument is non-const; does it modify rect? if (SDL_BlitSurface(surface_, srcrect ? &*srcrect : nullptr, dst.Get(), &tmpdstrect) != 0) - throw Exception("SDL_BlitSurface failed"); + throw Exception("SDL_BlitSurface"); } void Surface::BlitScaled(const Optional& srcrect, Surface& dst, const Optional& dstrect) { @@ -109,7 +109,7 @@ void Surface::BlitScaled(const Optional& srcrect, Surface& dst, const Opti if (dstrect) tmpdstrect = *dstrect; if (SDL_BlitScaled(surface_, srcrect ? &*srcrect : nullptr, dst.Get(), dstrect ? &tmpdstrect : nullptr) != 0) - throw Exception("SDL_BlitScaled failed"); + throw Exception("SDL_BlitScaled"); } Surface::LockHandle Surface::Lock() { @@ -125,68 +125,68 @@ Rect Surface::GetClipRect() const { Uint32 Surface::GetColorKey() const { Uint32 key; if (SDL_GetColorKey(surface_, &key) != 0) - throw Exception("SDL_GetColorKey failed"); + throw Exception("SDL_GetColorKey"); return key; } Uint8 Surface::GetAlphaMod() const { Uint8 alpha; if (SDL_GetSurfaceAlphaMod(surface_, &alpha) != 0) - throw Exception("SDL_GetSurfaceAlphaMod failed"); + throw Exception("SDL_GetSurfaceAlphaMod"); return alpha; } SDL_BlendMode Surface::GetBlendMode() const { SDL_BlendMode blendMode; if (SDL_GetSurfaceBlendMode(surface_, &blendMode) != 0) - throw Exception("SDL_GetSurfaceBlendMode failed"); + throw Exception("SDL_GetSurfaceBlendMode"); return blendMode; } void Surface::GetColorMod(Uint8& r, Uint8& g, Uint8& b) const { if (SDL_GetSurfaceColorMod(surface_, &r, &g, &b) != 0) - throw Exception("SDL_GetSurfaceColorMod failed"); + throw Exception("SDL_GetSurfaceColorMod"); } Surface& Surface::SetClipRect(const Optional& rect) { if (SDL_SetClipRect(surface_, rect ? &*rect : nullptr) != 0) - throw Exception("SDL_SetClipRect failed"); + throw Exception("SDL_SetClipRect"); return *this; } Surface& Surface::SetColorKey(bool flag, Uint32 key) { if (SDL_SetColorKey(surface_, flag, key) != 0) - throw Exception("SDL_SetColorKey failed"); + throw Exception("SDL_SetColorKey"); return *this; } Surface& Surface::SetAlphaMod(Uint8 alpha) { if (SDL_SetSurfaceAlphaMod(surface_, alpha) != 0) - throw Exception("SDL_SetSurfaceAlphaMod failed"); + throw Exception("SDL_SetSurfaceAlphaMod"); return *this; } Surface& Surface::SetBlendMode(SDL_BlendMode blendMode) { if (SDL_SetSurfaceBlendMode(surface_, blendMode) != 0) - throw Exception("SDL_SetSurfaceBlendMode failed"); + throw Exception("SDL_SetSurfaceBlendMode"); return *this; } Surface& Surface::SetColorMod(Uint8 r, Uint8 g, Uint8 b) { if (SDL_SetSurfaceColorMod(surface_, r, g, b) != 0) - throw Exception("SDL_SetSurfaceColorMod failed"); + throw Exception("SDL_SetSurfaceColorMod"); return *this; } Surface& Surface::SetRLE(bool flag) { if (SDL_SetSurfaceRLE(surface_, flag ? 1 : 0) != 0) - throw Exception("SDL_SetSurfaceRLE failed"); + throw Exception("SDL_SetSurfaceRLE"); return *this; } Surface& Surface::FillRect(const Optional& rect, Uint32 color) { if (SDL_FillRect(surface_, rect ? &*rect : nullptr, color) != 0) - throw Exception("SDL_FillRect failed"); + throw Exception("SDL_FillRect"); return *this; } @@ -197,7 +197,7 @@ Surface& Surface::FillRects(const Rect* rects, int count, Uint32 color) { sdl_rects.emplace_back(*r); if (SDL_FillRects(surface_, sdl_rects.data(), sdl_rects.size(), color) != 0) - throw Exception("SDL_FillRects failed"); + throw Exception("SDL_FillRects"); return *this; } diff --git a/SDL2pp/SurfaceLock.cc b/SDL2pp/SurfaceLock.cc index 162e80d..3504363 100644 --- a/SDL2pp/SurfaceLock.cc +++ b/SDL2pp/SurfaceLock.cc @@ -1,6 +1,6 @@ /* libSDL2pp - C++11 bindings/wrapper for SDL2 - Copyright (C) 2014 Dmitry Marakasov + Copyright (C) 2014-2015 Dmitry Marakasov This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -33,7 +33,7 @@ Surface::LockHandle::LockHandle() : surface_(nullptr) { Surface::LockHandle::LockHandle(Surface* surface) : surface_(surface) { if (SDL_MUSTLOCK(surface_->Get())) { if (SDL_LockSurface(surface_->Get())) - throw Exception("SDL_LockSurface failed"); + throw Exception("SDL_LockSurface"); } } diff --git a/SDL2pp/Texture.cc b/SDL2pp/Texture.cc index b895617..d17f245 100644 --- a/SDL2pp/Texture.cc +++ b/SDL2pp/Texture.cc @@ -45,24 +45,24 @@ Texture::Texture(SDL_Texture* texture) : texture_(texture) { Texture::Texture(Renderer& renderer, Uint32 format, int access, int w, int h) { if ((texture_ = SDL_CreateTexture(renderer.Get(), format, access, w, h)) == nullptr) - throw Exception("SDL_CreateTexture failed"); + throw Exception("SDL_CreateTexture"); } #ifdef SDL2PP_WITH_IMAGE Texture::Texture(Renderer& renderer, RWops& rwops) { if ((texture_ = IMG_LoadTexture_RW(renderer.Get(), rwops.Get(), 0)) == nullptr) - throw Exception("IMG_LoadTexture_RW failed"); + throw Exception("IMG_LoadTexture_RW"); } Texture::Texture(Renderer& renderer, const std::string& path) { if ((texture_ = IMG_LoadTexture(renderer.Get(), path.c_str())) == nullptr) - throw Exception("IMG_LoadTexture failed"); + throw Exception("IMG_LoadTexture"); } #endif Texture::Texture(Renderer& renderer, const Surface& surface) { if ((texture_ = SDL_CreateTextureFromSurface(renderer.Get(), surface.Get())) == nullptr) - throw Exception("SDL_CreateTextureFromSurface failed"); + throw Exception("SDL_CreateTextureFromSurface"); } Texture::~Texture() { @@ -90,31 +90,31 @@ SDL_Texture* Texture::Get() const { Texture& Texture::Update(const Optional& rect, const void* pixels, int pitch) { if (SDL_UpdateTexture(texture_, rect ? &*rect : nullptr, pixels, pitch) != 0) - throw Exception("SDL_UpdateTexture failed"); + throw Exception("SDL_UpdateTexture"); return *this; } Texture& Texture::UpdateYUV(const Optional& rect, const Uint8* yplane, int ypitch, const Uint8* uplane, int upitch, const Uint8* vplane, int vpitch) { if (SDL_UpdateYUVTexture(texture_, rect ? &*rect : nullptr, yplane, ypitch, uplane, upitch, vplane, vpitch) != 0) - throw Exception("SDL_UpdateYUVTexture failed"); + throw Exception("SDL_UpdateYUVTexture"); return *this; } Texture& Texture::SetBlendMode(SDL_BlendMode blendMode) { if (SDL_SetTextureBlendMode(texture_, blendMode) != 0) - throw Exception("SDL_SetTextureBlendMode failed"); + throw Exception("SDL_SetTextureBlendMode"); return *this; } Texture& Texture::SetAlphaMod(Uint8 alpha) { if (SDL_SetTextureAlphaMod(texture_, alpha) != 0) - throw Exception("SDL_SetTextureAlphaMod failed"); + throw Exception("SDL_SetTextureAlphaMod"); return *this; } Texture& Texture::SetColorMod(Uint8 r, Uint8 g, Uint8 b) { if (SDL_SetTextureColorMod(texture_, r, g, b) != 0) - throw Exception("SDL_SetTextureColorMod failed"); + throw Exception("SDL_SetTextureColorMod"); return *this; } @@ -125,55 +125,55 @@ Texture::LockHandle Texture::Lock(const Optional& rect) { Uint32 Texture::GetFormat() const { Uint32 format; if (SDL_QueryTexture(texture_, &format, nullptr, nullptr, nullptr) != 0) - throw Exception("SDL_QueryTexture failed"); + throw Exception("SDL_QueryTexture"); return format; } int Texture::GetAccess() const { int access; if (SDL_QueryTexture(texture_, nullptr, &access, nullptr, nullptr) != 0) - throw Exception("SDL_QueryTexture failed"); + throw Exception("SDL_QueryTexture"); return access; } int Texture::GetWidth() const { int w; if (SDL_QueryTexture(texture_, nullptr, nullptr, &w, nullptr) != 0) - throw Exception("SDL_QueryTexture failed"); + throw Exception("SDL_QueryTexture"); return w; } int Texture::GetHeight() const { int h; if (SDL_QueryTexture(texture_, nullptr, nullptr, nullptr, &h) != 0) - throw Exception("SDL_QueryTexture failed"); + throw Exception("SDL_QueryTexture"); return h; } Point Texture::GetSize() const { int w, h; if (SDL_QueryTexture(texture_, nullptr, nullptr, &w, &h) != 0) - throw Exception("SDL_QueryTexture failed"); + throw Exception("SDL_QueryTexture"); return Point(w, h); } Uint8 Texture::GetAlphaMod() const { Uint8 alpha; if (SDL_GetTextureAlphaMod(texture_, &alpha) != 0) - throw Exception("SDL_GetTextureAlphaMod failed"); + throw Exception("SDL_GetTextureAlphaMod"); return alpha; } SDL_BlendMode Texture::GetBlendMode() const { SDL_BlendMode mode; if (SDL_GetTextureBlendMode(texture_, &mode) != 0) - throw Exception("SDL_GetTextureBlendMode failed"); + throw Exception("SDL_GetTextureBlendMode"); return mode; } void Texture::GetColorMod(Uint8& r, Uint8& g, Uint8& b) const { if (SDL_GetTextureColorMod(texture_, &r, &g, &b) != 0) - throw Exception("SDL_GetTextureBlendMode failed"); + throw Exception("SDL_GetTextureColorMod"); } } diff --git a/SDL2pp/TextureLock.cc b/SDL2pp/TextureLock.cc index 0740e05..9a7ddd2 100644 --- a/SDL2pp/TextureLock.cc +++ b/SDL2pp/TextureLock.cc @@ -1,6 +1,6 @@ /* libSDL2pp - C++11 bindings/wrapper for SDL2 - Copyright (C) 2013-2014 Dmitry Marakasov + Copyright (C) 2013-2015 Dmitry Marakasov This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -33,7 +33,7 @@ Texture::LockHandle::LockHandle() : texture_(nullptr), pixels_(nullptr), pitch_( Texture::LockHandle::LockHandle(Texture* texture, const Optional& rect) : texture_(texture) { if (SDL_LockTexture(texture_->Get(), rect ? &*rect : nullptr, &pixels_, &pitch_) != 0) - throw Exception("SDL_LockTexture failed"); + throw Exception("SDL_LockTexture"); } Texture::LockHandle::LockHandle(Texture::LockHandle&& other) noexcept : texture_(other.texture_), pixels_(other.pixels_), pitch_(other.pitch_) { diff --git a/SDL2pp/Wav.cc b/SDL2pp/Wav.cc index 13f4287..fbbfba4 100644 --- a/SDL2pp/Wav.cc +++ b/SDL2pp/Wav.cc @@ -1,6 +1,6 @@ /* libSDL2pp - C++11 bindings/wrapper for SDL2 - Copyright (C) 2014 Dmitry Marakasov + Copyright (C) 2014-2015 Dmitry Marakasov This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -28,12 +28,12 @@ namespace SDL2pp { Wav::Wav(const std::string& file) { if (SDL_LoadWAV(file.c_str(), &spec_, &audio_buffer_, &audio_length_) == nullptr) - throw Exception("SDL_LoadWAV failed"); + throw Exception("SDL_LoadWAV"); } Wav::Wav(RWops& rwops) { if (SDL_LoadWAV_RW(rwops.Get(), 0, &spec_, &audio_buffer_, &audio_length_) == nullptr) - throw Exception("SDL_LoadWAV failed"); + throw Exception("SDL_LoadWAV_RW"); } Wav::~Wav() { diff --git a/SDL2pp/Window.cc b/SDL2pp/Window.cc index bef5db0..687e58d 100644 --- a/SDL2pp/Window.cc +++ b/SDL2pp/Window.cc @@ -31,7 +31,7 @@ Window::Window(SDL_Window* window) : window_(window) { Window::Window(const std::string& title, int x, int y, int w, int h, Uint32 flags) { if ((window_ = SDL_CreateWindow(title.c_str(), x, y, w, h, flags)) == nullptr) - throw Exception("SDL_CreateWindow failed"); + throw Exception("SDL_CreateWindow"); } Window::~Window() { @@ -116,7 +116,7 @@ Window& Window::Show() { Window& Window::SetFullscreen(int flags) { if (SDL_SetWindowFullscreen(window_, flags) != 0) - throw Exception("SDL_SetWindowFullscreen failed"); + throw Exception("SDL_SetWindowFullscreen"); return *this; } @@ -136,7 +136,7 @@ float Window::GetBrightness() const { Window& Window::SetBrightness(float brightness) { if (SDL_SetWindowBrightness(window_, brightness) != 0) - throw Exception("SDL_SetWindowBrightness failed"); + throw Exception("SDL_SetWindowBrightness"); return *this; } diff --git a/examples/audio_sine.cc b/examples/audio_sine.cc index 14523cb..38477bf 100644 --- a/examples/audio_sine.cc +++ b/examples/audio_sine.cc @@ -1,6 +1,6 @@ /* libSDL2pp - C++11 bindings/wrapper for SDL2 - Copyright (C) 2013-2014 Dmitry Marakasov + Copyright (C) 2013-2015 Dmitry Marakasov This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -26,7 +26,6 @@ #include #include #include -#include using namespace SDL2pp; @@ -60,8 +59,6 @@ int Run() { int main() { try { return Run(); - } catch (Exception& e) { - std::cerr << "Error: " << e.what() << " (" << e.GetSDLError() << ")" << std::endl; } catch (std::exception& e) { std::cerr << "Error: " << e.what() << std::endl; } diff --git a/examples/audio_wav.cc b/examples/audio_wav.cc index b6f69c8..7909667 100644 --- a/examples/audio_wav.cc +++ b/examples/audio_wav.cc @@ -1,6 +1,6 @@ /* libSDL2pp - C++11 bindings/wrapper for SDL2 - Copyright (C) 2013-2014 Dmitry Marakasov + Copyright (C) 2013-2015 Dmitry Marakasov This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -28,7 +28,6 @@ #include #include #include -#include using namespace SDL2pp; @@ -70,8 +69,6 @@ int Run() { int main() { try { return Run(); - } catch (Exception& e) { - std::cerr << "Error: " << e.what() << " (" << e.GetSDLError() << ")" << std::endl; } catch (std::exception& e) { std::cerr << "Error: " << e.what() << std::endl; } diff --git a/examples/image.cc b/examples/image.cc index c47eeb1..39fbb24 100644 --- a/examples/image.cc +++ b/examples/image.cc @@ -1,6 +1,6 @@ /* libSDL2pp - C++11 bindings/wrapper for SDL2 - Copyright (C) 2013-2014 Dmitry Marakasov + Copyright (C) 2013-2015 Dmitry Marakasov This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -30,7 +30,6 @@ #include #include #include -#include using namespace SDL2pp; @@ -82,8 +81,6 @@ int Run() { int main() { try { return Run(); - } catch (Exception& e) { - std::cerr << "Error: " << e.what() << " (" << e.GetSDLError() << ")" << std::endl; } catch (std::exception& e) { std::cerr << "Error: " << e.what() << std::endl; } diff --git a/examples/lines.cc b/examples/lines.cc index 90c2307..652cb9e 100644 --- a/examples/lines.cc +++ b/examples/lines.cc @@ -1,6 +1,6 @@ /* libSDL2pp - C++11 bindings/wrapper for SDL2 - Copyright (C) 2013-2014 Dmitry Marakasov + Copyright (C) 2013-2015 Dmitry Marakasov This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -26,7 +26,6 @@ #include #include #include -#include using namespace SDL2pp; @@ -94,8 +93,6 @@ int Run() { int main() { try { return Run(); - } catch (Exception& e) { - std::cerr << "Error: " << e.what() << " (" << e.GetSDLError() << ")" << std::endl; } catch (std::exception& e) { std::cerr << "Error: " << e.what() << std::endl; } diff --git a/examples/rendertarget.cc b/examples/rendertarget.cc index 9c21279..6e53fab 100644 --- a/examples/rendertarget.cc +++ b/examples/rendertarget.cc @@ -27,7 +27,6 @@ #include #include #include -#include using namespace SDL2pp; @@ -120,8 +119,6 @@ int Run() { int main() { try { return Run(); - } catch (Exception& e) { - std::cerr << "Error: " << e.what() << " (" << e.GetSDLError() << ")" << std::endl; } catch (std::exception& e) { std::cerr << "Error: " << e.what() << std::endl; } diff --git a/examples/sprites.cc b/examples/sprites.cc index cc4a667..e11f7c6 100644 --- a/examples/sprites.cc +++ b/examples/sprites.cc @@ -1,6 +1,6 @@ /* libSDL2pp - C++11 bindings/wrapper for SDL2 - Copyright (C) 2013-2014 Dmitry Marakasov + Copyright (C) 2013-2015 Dmitry Marakasov This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -27,7 +27,6 @@ #include #include #include -#include using namespace SDL2pp; @@ -93,8 +92,6 @@ int Run() { int main() { try { return Run(); - } catch (Exception& e) { - std::cerr << "Error: " << e.what() << " (" << e.GetSDLError() << ")" << std::endl; } catch (std::exception& e) { std::cerr << "Error: " << e.what() << std::endl; } diff --git a/examples/ttf.cc b/examples/ttf.cc index 43cf3c4..81f8f8c 100644 --- a/examples/ttf.cc +++ b/examples/ttf.cc @@ -1,6 +1,6 @@ /* libSDL2pp - C++11 bindings/wrapper for SDL2 - Copyright (C) 2013-2014 Dmitry Marakasov + Copyright (C) 2013-2015 Dmitry Marakasov This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -21,15 +21,12 @@ #include -//#include - #include #include #include #include #include #include -#include using namespace SDL2pp; @@ -89,8 +86,6 @@ int Run() { int main() { try { return Run(); - } catch (Exception& e) { - std::cerr << "Error: " << e.what() << " (" << e.GetSDLError() << ")" << std::endl; } catch (std::exception& e) { std::cerr << "Error: " << e.what() << std::endl; }