1 | #ifndef _theplu_yat_utility_exception_ |
---|
2 | #define _theplu_yat_utility_exception_ |
---|
3 | |
---|
4 | // $Id: Exception.h 4359 2023-08-23 01:28:46Z peter $ |
---|
5 | |
---|
6 | /* |
---|
7 | Copyright (C) 2005, 2006, 2007, 2008 Jari Häkkinen, Peter Johansson |
---|
8 | Copyright (C) 2010, 2020 Peter Johansson |
---|
9 | |
---|
10 | This file is part of the yat library, http://dev.thep.lu.se/yat |
---|
11 | |
---|
12 | The yat library is free software; you can redistribute it and/or |
---|
13 | modify it under the terms of the GNU General Public License as |
---|
14 | published by the Free Software Foundation; either version 3 of the |
---|
15 | License, or (at your option) any later version. |
---|
16 | |
---|
17 | The yat library is distributed in the hope that it will be useful, |
---|
18 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
20 | General Public License for more details. |
---|
21 | |
---|
22 | You should have received a copy of the GNU General Public License |
---|
23 | along with yat. If not, see <http://www.gnu.org/licenses/>. |
---|
24 | */ |
---|
25 | |
---|
26 | #include <stdexcept> |
---|
27 | #include <string> |
---|
28 | |
---|
29 | namespace theplu { |
---|
30 | namespace yat { |
---|
31 | namespace utility { |
---|
32 | |
---|
33 | /** |
---|
34 | \brief Class used for all invalid arguments detected within yat library. |
---|
35 | |
---|
36 | \since New in yat 0.19 |
---|
37 | */ |
---|
38 | class invalid_argument : public std::invalid_argument |
---|
39 | { |
---|
40 | public: |
---|
41 | /** |
---|
42 | \brief Constructor |
---|
43 | |
---|
44 | \param message message to be displayed using function what(). |
---|
45 | */ |
---|
46 | invalid_argument(const std::string& message); |
---|
47 | }; |
---|
48 | |
---|
49 | |
---|
50 | /** |
---|
51 | \brief Class used for all runtime error detected within yat library. |
---|
52 | */ |
---|
53 | class runtime_error : public std::runtime_error |
---|
54 | { |
---|
55 | public: |
---|
56 | /** |
---|
57 | \brief Constructor |
---|
58 | |
---|
59 | \param message message to be displayed using function what(). |
---|
60 | */ |
---|
61 | runtime_error(std::string message); |
---|
62 | }; |
---|
63 | |
---|
64 | |
---|
65 | /** |
---|
66 | \brief Class used for error reported from Commandline or Option. |
---|
67 | */ |
---|
68 | class cmd_error : public runtime_error |
---|
69 | { |
---|
70 | public: |
---|
71 | /** |
---|
72 | \brief Constructor |
---|
73 | |
---|
74 | \param message message to be displayed using function what(). |
---|
75 | */ |
---|
76 | cmd_error(std::string message); |
---|
77 | }; |
---|
78 | |
---|
79 | |
---|
80 | /** |
---|
81 | \brief Class that contains information reported via global |
---|
82 | variable errno. |
---|
83 | |
---|
84 | \since New in yat 0.7 |
---|
85 | */ |
---|
86 | class errno_error : public runtime_error |
---|
87 | { |
---|
88 | public: |
---|
89 | /** |
---|
90 | The error message, return from what(), is set to |
---|
91 | \a message + strerror(errno) |
---|
92 | */ |
---|
93 | errno_error(std::string message); |
---|
94 | }; |
---|
95 | |
---|
96 | /** |
---|
97 | \brief Class for errors reported from underlying GSL calls. |
---|
98 | |
---|
99 | GSL_error is used in the same way as C++ standard library |
---|
100 | exceptions. |
---|
101 | */ |
---|
102 | class GSL_error : public runtime_error |
---|
103 | { |
---|
104 | public: |
---|
105 | /** |
---|
106 | \brief Constructor to create an exception with a message. |
---|
107 | */ |
---|
108 | GSL_error(std::string message); |
---|
109 | |
---|
110 | /** |
---|
111 | \brief Constructor to create an exception with a message |
---|
112 | containg the GSL error description. |
---|
113 | */ |
---|
114 | GSL_error(std::string message, int gsl_status); |
---|
115 | }; |
---|
116 | |
---|
117 | |
---|
118 | /** |
---|
119 | \brief Class to report errors associated with IO operations. |
---|
120 | |
---|
121 | IO_error is used in the same way as C++ standard library |
---|
122 | exceptions. |
---|
123 | */ |
---|
124 | class IO_error : public runtime_error |
---|
125 | { |
---|
126 | public: |
---|
127 | /** |
---|
128 | \brief Constructor to create an exception with a message. |
---|
129 | */ |
---|
130 | IO_error(std::string message); |
---|
131 | }; |
---|
132 | |
---|
133 | }}} // of namespace utility, yat, and theplu |
---|
134 | |
---|
135 | #endif |
---|