From fbeff35aec612698bb0b09f5add66c888a8b0e3d Mon Sep 17 00:00:00 2001 From: Tulio Leao Date: Wed, 23 Mar 2022 23:43:32 -0300 Subject: [PATCH] Split SDLException into source and header --- src/openrct2-ui/SDLException.cpp | 28 +++++++++++++++++++++++++++ src/openrct2-ui/SDLException.h | 20 ++++--------------- src/openrct2-ui/libopenrct2ui.vcxproj | 1 + 3 files changed, 33 insertions(+), 16 deletions(-) create mode 100644 src/openrct2-ui/SDLException.cpp diff --git a/src/openrct2-ui/SDLException.cpp b/src/openrct2-ui/SDLException.cpp new file mode 100644 index 0000000000..feac6cc0c5 --- /dev/null +++ b/src/openrct2-ui/SDLException.cpp @@ -0,0 +1,28 @@ +/***************************************************************************** + * Copyright (c) 2014-2022 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#include "SDLException.h" + +#include + +SDLException::SDLException(const std::string& message) + : runtime_error(message.c_str()) +{ +} + +SDLException::SDLException(const char* message) + : runtime_error(message) +{ +} + +void SDLException::Throw(const char* call) +{ + std::string message = std::string(call) + ": " + std::string(SDL_GetError()); + throw SDLException(message); +} diff --git a/src/openrct2-ui/SDLException.h b/src/openrct2-ui/SDLException.h index 5f9b44a5f3..60a380fda2 100644 --- a/src/openrct2-ui/SDLException.h +++ b/src/openrct2-ui/SDLException.h @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2014-2020 OpenRCT2 developers + * Copyright (c) 2014-2022 OpenRCT2 developers * * For a complete list of all authors, please refer to contributors.md * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 @@ -9,7 +9,6 @@ #pragma once -#include #include #include @@ -19,24 +18,13 @@ class SDLException : public std::runtime_error { public: - explicit SDLException(const std::string& message) - : runtime_error(message.c_str()) - { - SDL_GetError(); - } + explicit SDLException(const std::string& message); - explicit SDLException(const char* message) - : runtime_error(message) - { - } + explicit SDLException(const char* message); /** * Throws an SDL exception with a message containing the given call information * and the message given by SDL_GetError. */ - static void Throw(const char* call) - { - std::string message = std::string(call) + ": " + std::string(SDL_GetError()); - throw SDLException(message); - } + static void Throw(const char* call); }; diff --git a/src/openrct2-ui/libopenrct2ui.vcxproj b/src/openrct2-ui/libopenrct2ui.vcxproj index 635125faaf..7cc750c533 100644 --- a/src/openrct2-ui/libopenrct2ui.vcxproj +++ b/src/openrct2-ui/libopenrct2ui.vcxproj @@ -109,6 +109,7 @@ +