Split SDLException into source and header

This commit is contained in:
Tulio Leao 2022-03-23 23:43:32 -03:00
parent 0e607ed0a3
commit fbeff35aec
3 changed files with 33 additions and 16 deletions

View File

@ -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 <SDL.h>
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);
}

View File

@ -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 <SDL.h>
#include <stdexcept>
#include <string>
@ -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);
};

View File

@ -109,6 +109,7 @@
<ClCompile Include="scripting\CustomMenu.cpp" />
<ClCompile Include="scripting\CustomWindow.cpp" />
<ClCompile Include="scripting\UiExtensions.cpp" />
<ClCompile Include="SDLException.cpp" />
<ClCompile Include="TextComposition.cpp" />
<ClCompile Include="title\TitleSequencePlayer.cpp" />
<ClCompile Include="Ui.cpp" />