The Battle for Wesnoth  1.19.0-dev
exception.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2011 - 2024
3  by Mark de Wever <koraq@xs4all.nl>
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 /**
17  * @file
18  * Contains the exceptions thrown by the @ref gui2::iteration::iterator classes.
19  */
20 
21 #pragma once
22 
24 
25 #include <stdexcept>
26 #include <string>
27 
28 namespace gui2::iteration
29 {
30 
31 /**
32  * Thrown when deferring an invalid iterator.
33  *
34  * Invalid means the initial state at_end() == true.
35  */
36 class logic_error final : public std::logic_error, public lua_jailbreak_exception
37 {
38 public:
39  explicit logic_error(const std::string& message)
40  : std::logic_error("GUI2 ITERATOR: " + message)
42  {
43  this->store();
44  }
45 
46 private:
48 };
49 
50 /**
51  * Thrown when moving an invalid iterator.
52  *
53  * Invalid means the initial state at_end() == true.
54  */
55 class range_error final : public std::range_error, public lua_jailbreak_exception
56 {
57 public:
58  explicit range_error(const std::string& message)
59  : std::range_error("GUI2 ITERATOR: " + message)
61  {
62  this->store();
63  }
64 
65 private:
67 };
68 
69 } // namespace gui2::iteration
Main class to show messages to the user.
Definition: message.hpp:36
Thrown when deferring an invalid iterator.
Definition: exception.hpp:37
logic_error(const std::string &message)
Definition: exception.hpp:39
Thrown when moving an invalid iterator.
Definition: exception.hpp:56
range_error(const std::string &message)
Definition: exception.hpp:58
Base class for exceptions that want to be thrown 'through' lua.
void store() const noexcept
Stores a copy the current exception to be rethrown.
#define IMPLEMENT_LUA_JAILBREAK_EXCEPTION(type)
Helper macro for classes deriving from lua_jailbreak_exception.