1 /*
2    Copyright (C) 2011 - 2018 by Mark de Wever <koraq@xs4all.nl>
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 /**
16  * @file
17  * Contains the exceptions thrown by the @ref gui2::iteration::iterator classes.
18  */
19 
20 #pragma once
21 
22 #include "lua_jailbreak_exception.hpp"
23 
24 #include <stdexcept>
25 #include <string>
26 
27 namespace gui2
28 {
29 
30 namespace iteration
31 {
32 
33 /**
34  * Thrown when deferring an invalid iterator.
35  *
36  * Invalid means the initial state at_end() == true.
37  */
38 class logic_error : public std::logic_error, public lua_jailbreak_exception
39 {
40 public:
logic_error(const std::string & message)41 	explicit logic_error(const std::string& message)
42 		: std::logic_error("GUI2 ITERATOR: " + message)
43 		, lua_jailbreak_exception()
44 	{
45 	}
46 
47 private:
48 	IMPLEMENT_LUA_JAILBREAK_EXCEPTION(logic_error)
49 };
50 
51 /**
52  * Thrown when moving an invalid iterator.
53  *
54  * Invalid means the initial state at_end() == true.
55  */
56 class range_error : public std::range_error, public lua_jailbreak_exception
57 {
58 public:
range_error(const std::string & message)59 	explicit range_error(const std::string& message)
60 		: std::range_error("GUI2 ITERATOR: " + message)
61 		, lua_jailbreak_exception()
62 	{
63 	}
64 
65 private:
66 	IMPLEMENT_LUA_JAILBREAK_EXCEPTION(range_error)
67 };
68 
69 } // namespace iteration
70 
71 } // namespace gui2
72