The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
game_errors.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 by David White <[email protected]>
3  Copyright (C) 2005 - 2016 by Yann Dirson <[email protected]>
4  Part of the Battle for Wesnoth Project http://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 #ifndef GAME_ERRORS_HPP_INCLUDED
16 #define GAME_ERRORS_HPP_INCLUDED
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 /**
59  * Exception used to signal that the user has decided to abort a game,
60  * and to load another game instead.
61  */
64 {
65 public:
66 
69  {
70  }
71 
73  const std::string& game_
74  , const bool show_replay_
75  , const bool cancel_orders_
76  , const bool select_difficulty_
77  , const std::string& difficulty_
78  , bool skip_version_check_ = false)
80  {
81  game = game_;
82  show_replay = show_replay_;
83  cancel_orders = cancel_orders_;
84  select_difficulty = select_difficulty_;
85  difficulty = difficulty_;
86  skip_version_check = skip_version_check_;
87  }
88 
89  static std::string game;
90  static bool show_replay;
91  static bool cancel_orders;
92  static bool select_difficulty;
94  static bool skip_version_check;
95 
96 private:
97 
99 };
100 
101 }
102 
103 #endif
static std::string game
Definition: game_errors.hpp:89
const wesnothd::game & game_
Definition: game.cpp:1393
#define IMPLEMENT_LUA_JAILBREAK_EXCEPTION(type)
Helper macro for classes deriving from tlua_jailbreak_exception.
static bool skip_version_check
Definition: game_errors.hpp:94
Error used when game loading fails.
Definition: game_errors.hpp:30
Error used when game saving fails.
Definition: game_errors.hpp:38
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
Base class for exceptions that want to be thrown 'through' lua.
Exception used to signal that the user has decided to abort a game, and to load another game instead...
Definition: game_errors.hpp:62
lua_error(const std::string &msg)
Definition: game_errors.hpp:54
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
Definition: debugger.cpp:112
Base class for all the errors encountered by the engine.
Definition: exceptions.hpp:27
game_error(const std::string &msg)
Definition: game_errors.hpp:47
GLsizei const GLcharARB ** string
Definition: glew.h:4503
static std::string difficulty
Definition: game_errors.hpp:93
load_game_exception(const std::string &game_, const bool show_replay_, const bool cancel_orders_, const bool select_difficulty_, const std::string &difficulty_, bool skip_version_check_=false)
Definition: game_errors.hpp:72
Error used to report an error in a lua script or in the lua interpreter.
Definition: game_errors.hpp:53