The Battle for Wesnoth  1.15.12+dev
wesnothd_connection_error.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2011 - 2018 by Sergey Popov <loonycyborg@gmail.com>
3  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #pragma once
16 
17 #include "exceptions.hpp"
19 
20 #include <boost/system/error_code.hpp>
21 
22 /** An error occurred during when trying to communicate with the wesnothd server. */
23 struct wesnothd_error : public game::error
24 {
25  wesnothd_error(const std::string& error)
26  : game::error(error)
27  {
28  }
29 };
30 
31 /**
32  * Error used when the client is rejected by the MP server.
33  * Technically, this is not an error but the only way to handle the condition is as if it were an error.
34  */
36 {
37  wesnothd_rejected_client_error(const std::string& msg)
38  : game::error(msg)
39  {
40  }
41 };
42 
43 /**
44  * We received invalid data from wesnothd during a game
45  * This means we cannot continue with the game but we can stay connected to wesnothd and start a new game.
46  * TODO: find a short name
47  */
49 {
50  ingame_wesnothd_error(const std::string& error)
51  : wesnothd_error(error)
52  {
53  }
54 
56 };
57 
59 {
60  leavegame_wesnothd_error(const std::string& error)
61  : ingame_wesnothd_error(error)
62  {
63  }
64 };
65 
66 /**
67  * An error occurred inside the underlying network communication code (boost asio)
68  * TODO: find a short name
69  */
71 {
72  wesnothd_connection_error(const boost::system::error_code& error, const std::string& msg = "")
73  : wesnothd_error(error.message())
74  , user_message(msg)
75  {
76  }
77 
78  /** User-friendly and potentially translated message for use in the UI. */
79  std::string user_message;
80 
82 };
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:109
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:27
std::string message
Definition: exceptions.hpp:29
Base class for exceptions that want to be thrown &#39;through&#39; lua.