The Battle for Wesnoth  1.17.0-dev
wesnothd_connection_error.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2011 - 2021
3  by Sergey Popov <loonycyborg@gmail.com>
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 #include <boost/system/error_code.hpp>
22 
23 /** An error occurred during when trying to communicate with the wesnothd server. */
24 struct wesnothd_error : public game::error
25 {
26  wesnothd_error(const std::string& error)
27  : game::error(error)
28  {
29  }
30 };
31 
32 /**
33  * Error used when the client is rejected by the MP server.
34  * Technically, this is not an error but the only way to handle the condition is as if it were an error.
35  */
37 {
38  wesnothd_rejected_client_error(const std::string& msg)
39  : game::error(msg)
40  {
41  }
42 };
43 
44 /**
45  * We received invalid data from wesnothd during a game
46  * This means we cannot continue with the game but we can stay connected to wesnothd and start a new game.
47  * TODO: find a short name
48  */
50 {
51  ingame_wesnothd_error(const std::string& error)
52  : wesnothd_error(error)
53  {
54  }
55 
57 };
58 
60 {
61  leavegame_wesnothd_error(const std::string& error)
62  : ingame_wesnothd_error(error)
63  {
64  }
65 };
66 
67 /**
68  * An error occurred inside the underlying network communication code (boost asio)
69  * TODO: find a short name
70  */
72 {
73  wesnothd_connection_error(const boost::system::error_code& error, const std::string& msg = "")
74  : wesnothd_error(error.message())
75  , user_message(msg)
76  {
77  }
78 
79  /** User-friendly and potentially translated message for use in the UI. */
80  std::string user_message;
81 
83 };
An error occurred inside the underlying network communication code (boost asio) TODO: find a short na...
An error occurred during when trying to communicate with the wesnothd server.
leavegame_wesnothd_error(const std::string &error)
Error used when the client is rejected by the MP server.
#define IMPLEMENT_LUA_JAILBREAK_EXCEPTION(type)
Helper macro for classes deriving from lua_jailbreak_exception.
wesnothd_rejected_client_error(const std::string &msg)
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
Definition: debugger.cpp:110
wesnothd_error(const std::string &error)
std::string user_message
User-friendly and potentially translated message for use in the UI.
ingame_wesnothd_error(const std::string &error)
We received invalid data from wesnothd during a game This means we cannot continue with the game but ...
wesnothd_connection_error(const boost::system::error_code &error, const std::string &msg="")
Base class for all the errors encountered by the engine.
Definition: exceptions.hpp:28
std::string message
Definition: exceptions.hpp:30
Base class for exceptions that want to be thrown &#39;through&#39; lua.