Rename exception classes to avoid t- prefix

This commit is contained in:
Celtic Minstrel 2016-11-04 03:10:27 -04:00
parent a498ceafe7
commit e0614251c4
18 changed files with 56 additions and 56 deletions

View File

@ -43,12 +43,12 @@ MAKE_ENUM(LEVEL_RESULT,
* Exception used to escape form the ai or ui code to playsingle_controller::play_side.
* Never thrown during replays.
*/
class return_to_play_side_exception : public tlua_jailbreak_exception, public std::exception
class return_to_play_side_exception : public lua_jailbreak_exception, public std::exception
{
public:
return_to_play_side_exception()
: tlua_jailbreak_exception()
: lua_jailbreak_exception()
, std::exception()
{
}
@ -59,13 +59,13 @@ private:
};
class quit_game_exception
: public tlua_jailbreak_exception
: public lua_jailbreak_exception
, public std::exception
{
public:
quit_game_exception()
: tlua_jailbreak_exception()
: lua_jailbreak_exception()
, std::exception()
{
}

View File

@ -36,12 +36,12 @@ namespace iterator
*
* Invalid means the initial state at_end() == true.
*/
class tlogic_error : public std::logic_error, public tlua_jailbreak_exception
class tlogic_error : public std::logic_error, public lua_jailbreak_exception
{
public:
explicit tlogic_error(const std::string& message)
: std::logic_error("GUI2 ITERATOR: " + message)
, tlua_jailbreak_exception()
, lua_jailbreak_exception()
{
}
@ -54,12 +54,12 @@ private:
*
* Invalid means the initial state at_end() == true.
*/
class trange_error : public std::range_error, public tlua_jailbreak_exception
class trange_error : public std::range_error, public lua_jailbreak_exception
{
public:
explicit trange_error(const std::string& message)
: std::range_error("GUI2 ITERATOR: " + message)
, tlua_jailbreak_exception()
, lua_jailbreak_exception()
{
}

View File

@ -528,7 +528,7 @@ static surface load_image_sub_file(const image::locator &loc)
try {
surf = (*mod)(surf);
} catch(const image::modification::texception& e) {
} catch(const image::modification::imod_exception& e) {
ERR_CFG << "Failed to apply a modification to an image:\n"
<< "Image: " << loc.get_filename() << ".\n"
<< "Modifications: " << loc.get_modifications() << ".\n"

View File

@ -112,12 +112,12 @@ modification* decode_modification(const std::string& encoded_mod)
} // end anon namespace
modification::texception::texception(const std::stringstream& message_stream)
modification::imod_exception::imod_exception(const std::stringstream& message_stream)
: message(message_stream.str())
{
}
modification::texception::texception(const std::string& message)
modification::imod_exception::imod_exception(const std::string& message)
: message(message)
{
}
@ -262,7 +262,7 @@ surface blit_modification::operator()(const surface& src) const
<< x_ << "' larger than destination image's width '"
<< src->w << "' no blitting performed.\n";
throw texception(sstr);
throw imod_exception(sstr);
}
if(y_ >= src->h) {
@ -271,7 +271,7 @@ surface blit_modification::operator()(const surface& src) const
<< y_ << "' larger than destination image's height '"
<< src->h << "' no blitting performed.\n";
throw texception(sstr);
throw imod_exception(sstr);
}
if(surf_->w + x_ > src->w) {
@ -280,7 +280,7 @@ surface blit_modification::operator()(const surface& src) const
<< x_ + surf_->w << "' larger than destination image's width '"
<< src->w << "' no blitting performed.\n";
throw texception(sstr);
throw imod_exception(sstr);
}
if(surf_->h + y_ > src->h) {
@ -289,7 +289,7 @@ surface blit_modification::operator()(const surface& src) const
<< y_ + surf_->h << "' larger than destination image's height '"
<< src->h << "' no blitting performed.\n";
throw texception(sstr);
throw imod_exception(sstr);
}
surface nsrc = make_neutral_surface(src);

View File

@ -61,8 +61,8 @@ class modification
public:
/** Exception thrown by the operator() when an error occurs. */
struct texception
: public tlua_jailbreak_exception
struct imod_exception
: public lua_jailbreak_exception
{
/**
* Constructor.
@ -72,7 +72,7 @@ public:
* @param message_stream Stream with the error message regarding
* the failed operation.
*/
texception(const std::stringstream& message_stream);
imod_exception(const std::stringstream& message_stream);
/**
* Constructor.
@ -82,16 +82,16 @@ public:
* @param message String with the error message regarding
* the failed operation.
*/
texception(const std::string& message);
imod_exception(const std::string& message);
~texception() throw() {}
~imod_exception() throw() {}
/** The error message regarding the failed operation. */
const std::string message;
private:
IMPLEMENT_LUA_JAILBREAK_EXCEPTION(texception)
IMPLEMENT_LUA_JAILBREAK_EXCEPTION(imod_exception)
};
/// Decodes modifications from a modification string

View File

@ -16,28 +16,28 @@
#include <cassert>
tlua_jailbreak_exception *tlua_jailbreak_exception::jailbreak_exception = nullptr;
lua_jailbreak_exception *lua_jailbreak_exception::jailbreak_exception = nullptr;
void tlua_jailbreak_exception::store() const throw()
void lua_jailbreak_exception::store() const throw()
{
/*
* It should not be possible to call this function with an exception still
* pending. It could happen if the code doesn't call
* tlua_jailbreak_exception::rethrow() or a logic error in the code.
* lua_jailbreak_exception::rethrow() or a logic error in the code.
*/
assert(!jailbreak_exception);
jailbreak_exception = this->clone();
}
void tlua_jailbreak_exception::rethrow()
void lua_jailbreak_exception::rethrow()
{
if(!jailbreak_exception) {
return;
}
/*
* We need to call tlua_jailbreak_exception::clear() after the exception
* We need to call lua_jailbreak_exception::clear() after the exception
* is thrown. The most straightforward approach would be a small helper
* class calling clear in its destructor, but alas g++ then complains about
* an unused variable. Since we're sure there will be something thrown use
@ -54,7 +54,7 @@ void tlua_jailbreak_exception::rethrow()
assert(false);
}
void tlua_jailbreak_exception::clear() throw()
void lua_jailbreak_exception::clear() throw()
{
delete jailbreak_exception;
jailbreak_exception = nullptr;

View File

@ -23,10 +23,10 @@
* Classes inheriting from this class need to use the @ref
* IMPLEMENT_LUA_JAILBREAK_EXCEPTION macro in the class definition.
*/
class tlua_jailbreak_exception
class lua_jailbreak_exception
{
public:
virtual ~tlua_jailbreak_exception() throw() {}
virtual ~lua_jailbreak_exception() throw() {}
/** Stores a copy the current exception to be rethrown. */
void store() const throw();
@ -41,7 +41,7 @@ public:
protected:
/** The exception to be rethrown. */
static tlua_jailbreak_exception* jailbreak_exception;
static lua_jailbreak_exception* jailbreak_exception;
private:
@ -58,7 +58,7 @@ private:
*
* @returns A pointer to a copy of the class on the heap.
*/
virtual tlua_jailbreak_exception* clone() const = 0;
virtual lua_jailbreak_exception* clone() const = 0;
/**
* Executes the exception.
@ -76,12 +76,12 @@ private:
};
/**
* Helper macro for classes deriving from @ref tlua_jailbreak_exception.
* Helper macro for classes deriving from @ref lua_jailbreak_exception.
*
* @ref tlua_jailbreak_exception has several pure virtual functions, this
* @ref lua_jailbreak_exception has several pure virtual functions, this
* macro implements them properly. This macro needs to be placed in the
* definition of the most derived class, which uses @ref
* tlua_jailbreak_exception as baseclass.
* lua_jailbreak_exception as baseclass.
*
* @param type The type of the class whc
*/

View File

@ -75,17 +75,17 @@ struct load_game_metadata {
* and to load another game instead.
*/
class load_game_exception
: public tlua_jailbreak_exception, public std::exception
: public lua_jailbreak_exception, public std::exception
{
public:
load_game_exception(const std::string& fname)
: tlua_jailbreak_exception()
: lua_jailbreak_exception()
, data_(fname)
{
}
load_game_exception(load_game_metadata&& data)
: tlua_jailbreak_exception()
: lua_jailbreak_exception()
, data_(data)
{
}

View File

@ -939,7 +939,7 @@ int luaW_pcall_internal(lua_State *L, int nArgs, int nRets)
// Call the function.
int errcode = lua_pcall(L, nArgs, nRets, -2 - nArgs);
tlua_jailbreak_exception::rethrow();
lua_jailbreak_exception::rethrow();
// Remove the error handler.
lua_remove(L, error_handler_index);

View File

@ -20,7 +20,7 @@
#include "game_config.hpp"
#include "game_errors.hpp"
#include "log.hpp"
#include "lua_jailbreak_exception.hpp" // for tlua_jailbreak_exception
#include "lua_jailbreak_exception.hpp" // for lua_jailbreak_exception
#include "random_new.hpp"
#include "seed_rng.hpp"

View File

@ -29,7 +29,7 @@ static std::string create_error(const std::string& operation,
}
}
texception::texception(const std::string& operation, const bool use_sdl_error)
exception::exception(const std::string& operation, const bool use_sdl_error)
: game::error(create_error(operation, use_sdl_error))
{
}

View File

@ -25,7 +25,7 @@
namespace sdl
{
struct texception : public game::error
struct exception : public game::error
{
/**
* Constructor.
@ -36,7 +36,7 @@ struct texception : public game::error
* @p operation is the error message for the
* exception.
*/
texception(const std::string& operation, const bool use_sdl_error);
exception(const std::string& operation, const bool use_sdl_error);
};

View File

@ -32,21 +32,21 @@ twindow::twindow(const std::string& title,
, pixel_format_(SDL_PIXELFORMAT_UNKNOWN)
{
if(!window_) {
throw texception("Failed to create a SDL_Window object.", true);
throw exception("Failed to create a SDL_Window object.", true);
}
if(!SDL_CreateRenderer(window_, -1, render_flags)) {
throw texception("Failed to create a SDL_Renderer object.", true);
throw exception("Failed to create a SDL_Renderer object.", true);
}
SDL_RendererInfo info;
if(SDL_GetRendererInfo(*this, &info) != 0) {
throw texception("Failed to retrieve the information of the renderer.",
throw exception("Failed to retrieve the information of the renderer.",
true);
}
if(info.num_texture_formats == 0) {
throw texception("The renderer has no texture information available.\n",
throw exception("The renderer has no texture information available.\n",
false);
}
@ -98,7 +98,7 @@ void twindow::fill(Uint8 r, Uint8 g, Uint8 b, Uint8 a)
{
SDL_SetRenderDrawColor(*this, r, g, b, a);
if(SDL_RenderClear(*this) != 0) {
throw texception("Failed to clear the SDL_Renderer object.",
throw exception("Failed to clear the SDL_Renderer object.",
true);
}
}

View File

@ -112,12 +112,12 @@ public:
};
class quit
: public tlua_jailbreak_exception
: public lua_jailbreak_exception
{
public:
quit()
: tlua_jailbreak_exception()
: lua_jailbreak_exception()
{
}

View File

@ -42,7 +42,7 @@
#include "scripting/application_lua_kernel.hpp"
#include "scripting/plugins/context.hpp"
#include "scripting/plugins/manager.hpp"
#include "sdl/exception.hpp" // for texception
#include "sdl/exception.hpp" // for exception
#include "sdl/rect.hpp"
#include "serialization/binary_or_text.hpp" // for config_writer
#include "serialization/parser.hpp" // for read
@ -1082,7 +1082,7 @@ int main(int argc, char** argv)
std::cerr << e.what()
<< "\n\nGame will be aborted.\n";
error_exit(1);
} catch(const sdl::texception& e) {
} catch(const sdl::exception& e) {
std::cerr << e.what();
error_exit(1);
} catch(game::error &) {

View File

@ -87,7 +87,7 @@
try { \
try { \
a \
} catch(const tlua_jailbreak_exception &e) { \
} catch(const lua_jailbreak_exception &e) { \
e.store(); \
throw; \
} catch(const std::exception &e) { \
@ -98,7 +98,7 @@
/*this exception is used internaly by lua exceptions*/ \
throw; \
} catch(...) { \
assert(false && "Lua is swallowing an un-named exception... this indicates a programmer error, please derive all exceptions from either std::exception, or tlua_jailbreak_exception (and not with multiple inheritance pathways to either or this exception handler will not work!)"); \
assert(false && "Lua is swallowing an un-named exception... this indicates a programmer error, please derive all exceptions from either std::exception, or lua_jailbreak_exception (and not with multiple inheritance pathways to either or this exception handler will not work!)"); \
throw; \
} \
} catch(...) { \

View File

@ -26,7 +26,7 @@ struct wesnothd_error : public game::error
///We received invalid data from wesnothd during a game
///This means we cannot continue with the game but we can stay connected to wesnothd and start a new game
///TODO: find a short name
struct ingame_wesnothd_error : public wesnothd_error ,public tlua_jailbreak_exception
struct ingame_wesnothd_error : public wesnothd_error ,public lua_jailbreak_exception
{
ingame_wesnothd_error(const std::string& error) : wesnothd_error(error) {}
IMPLEMENT_LUA_JAILBREAK_EXCEPTION(ingame_wesnothd_error)
@ -35,7 +35,7 @@ struct ingame_wesnothd_error : public wesnothd_error ,public tlua_jailbreak_exce
///an error occured inside the underlying network comminication code (boost asio)
///TODO: find a short name
struct wesnothd_connection_error : public wesnothd_error ,public tlua_jailbreak_exception
struct wesnothd_connection_error : public wesnothd_error ,public lua_jailbreak_exception
{
wesnothd_connection_error(const boost::system::error_code& error) : wesnothd_error(error.message()) {}
IMPLEMENT_LUA_JAILBREAK_EXCEPTION(wesnothd_connection_error)

View File

@ -93,7 +93,7 @@ NORETURN void wml_exception(
/** Helper class, don't construct this directly. */
struct twml_exception
: public tlua_jailbreak_exception
: public lua_jailbreak_exception
{
twml_exception(const std::string& user_msg, const std::string& dev_msg)
: user_message(user_msg)