The Battle for Wesnoth  1.15.2+dev
exceptions.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 - 2018 by Guillaume Melquiond <guillaume.melquiond@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 "global.hpp"
18 
19 #include <exception>
20 #include <string>
21 
22 namespace game {
23 
24 /**
25  * Base class for all the errors encountered by the engine.
26  * It provides a field for storing custom messages related to the actual
27  * error.
28  */
29 struct error : std::exception
30 {
31  std::string message;
32 
33  error() : message() {}
34  error(const std::string &msg) : message(msg) {}
35  ~error() noexcept {}
36 
37  const char *what() const noexcept
38  {
39  return message.c_str();
40  }
41 };
42 
43 }
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
Definition: debugger.cpp:109
const char * what() const noexcept
Definition: exceptions.hpp:37
~error() noexcept
Definition: exceptions.hpp:35
Base class for all the errors encountered by the engine.
Definition: exceptions.hpp:29
std::string message
Definition: exceptions.hpp:31
error(const std::string &msg)
Definition: exceptions.hpp:34