The Battle for Wesnoth  1.19.6+dev
game_errors.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2005 - 2024
3  by Yann Dirson <ydirson@altern.org>
4  Copyright (C) 2003 by David White <dave@whitevine.net>
5  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY.
13 
14  See the COPYING file for more details.
15 */
16 
17 #pragma once
18 
19 #include "exceptions.hpp"
21 
22 namespace game {
23 
24 struct mp_server_error : public error {
25  mp_server_error(const std::string& msg) : error("MP server error: " + msg) {}
26 };
27 
28 /**
29  * Error used when game loading fails.
30  */
31 struct load_game_failed : public error {
33  load_game_failed(const std::string& msg) : error("load_game_failed: " + msg) {}
34 };
35 
36 /**
37  * Error used when game saving fails.
38  */
39 struct save_game_failed : public error {
41  save_game_failed(const std::string& msg) : error("save_game_failed: " + msg) {}
42 };
43 
44 /**
45  * Error used for any general game error, e.g. data files are corrupt.
46  */
47 struct game_error : public error {
48  game_error(const std::string& msg) : error("game_error: " + msg) {}
49 };
50 
51 /**
52  * Error used to report an error in a lua script or in the lua interpreter.
53  */
54 struct lua_error : public error {
55  lua_error(const std::string& msg) : error("lua_error: " + msg) {}
56  lua_error(const std::string& msg, const std::string& context) : error(context + ":\n " + msg) {}
57 };
58 
59 }
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
Definition: debugger.cpp:109
Base class for all the errors encountered by the engine.
Definition: exceptions.hpp:29
Error used for any general game error, e.g.
Definition: game_errors.hpp:47
game_error(const std::string &msg)
Definition: game_errors.hpp:48
Error used when game loading fails.
Definition: game_errors.hpp:31
load_game_failed(const std::string &msg)
Definition: game_errors.hpp:33
Error used to report an error in a lua script or in the lua interpreter.
Definition: game_errors.hpp:54
lua_error(const std::string &msg)
Definition: game_errors.hpp:55
lua_error(const std::string &msg, const std::string &context)
Definition: game_errors.hpp:56
mp_server_error(const std::string &msg)
Definition: game_errors.hpp:25
Error used when game saving fails.
Definition: game_errors.hpp:39
save_game_failed(const std::string &msg)
Definition: game_errors.hpp:41