The Battle for Wesnoth  1.15.12+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 <exception>
18 #include <string>
19 
20 namespace game {
21 
22 /**
23  * Base class for all the errors encountered by the engine.
24  * It provides a field for storing custom messages related to the actual
25  * error.
26  */
27 struct error : std::exception
28 {
29  std::string message;
30 
31  error() : message() {}
32  error(const std::string &msg) : message(msg) {}
33  ~error() noexcept {}
34 
35  const char *what() const noexcept
36  {
37  return message.c_str();
38  }
39 };
40 
41 }
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:35
~error() noexcept
Definition: exceptions.hpp:33
Base class for all the errors encountered by the engine.
Definition: exceptions.hpp:27
std::string message
Definition: exceptions.hpp:29
error(const std::string &msg)
Definition: exceptions.hpp:32