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