1 | #ifndef _theplu_yat_utility_exception_ |
---|
2 | #define _theplu_yat_utility_exception_ |
---|
3 | |
---|
4 | // $Id: Exception.h 1275 2008-04-11 06:10:12Z jari $ |
---|
5 | |
---|
6 | /* |
---|
7 | Copyright (C) 2005, 2006, 2007 Jari Häkkinen, Peter Johansson |
---|
8 | Copyright (C) 2008 Peter Johansson |
---|
9 | |
---|
10 | This file is part of the yat library, http://trac.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 2 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 this program; if not, write to the Free Software |
---|
24 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
---|
25 | 02111-1307, USA. |
---|
26 | */ |
---|
27 | |
---|
28 | #include <stdexcept> |
---|
29 | #include <string> |
---|
30 | |
---|
31 | #include <gsl/gsl_errno.h> |
---|
32 | |
---|
33 | namespace theplu { |
---|
34 | namespace yat { |
---|
35 | namespace utility { |
---|
36 | |
---|
37 | /** |
---|
38 | \brief Class used for error reported from Commandline or Option. |
---|
39 | */ |
---|
40 | class cmd_error : public std::runtime_error |
---|
41 | { |
---|
42 | public: |
---|
43 | /** |
---|
44 | \brief Constructor |
---|
45 | |
---|
46 | \param message message to be displayed using function what(). |
---|
47 | */ |
---|
48 | inline cmd_error(std::string message) |
---|
49 | : std::runtime_error(message) {} |
---|
50 | }; |
---|
51 | |
---|
52 | |
---|
53 | /** |
---|
54 | \brief Class for errors reported from underlying GSL calls. |
---|
55 | |
---|
56 | GSL_error is used in the same way as C++ standard library |
---|
57 | exceptions. |
---|
58 | */ |
---|
59 | class GSL_error : public std::runtime_error |
---|
60 | { |
---|
61 | public: |
---|
62 | /** |
---|
63 | \brief Constructor to create an exception with a message. |
---|
64 | */ |
---|
65 | inline GSL_error(std::string message) throw() |
---|
66 | : std::runtime_error("GSL_error: " + message) {} |
---|
67 | |
---|
68 | /** |
---|
69 | \brief Constructor to create an exception with a message |
---|
70 | containg the GSL error description. |
---|
71 | */ |
---|
72 | inline GSL_error(std::string message, int gsl_status) throw() |
---|
73 | : std::runtime_error("GSL_error: " + message + " " + |
---|
74 | gsl_strerror(gsl_status)) {} |
---|
75 | }; |
---|
76 | |
---|
77 | |
---|
78 | /** |
---|
79 | \brief Class to report errors associated with IO operations. |
---|
80 | |
---|
81 | IO_error is used in the same way as C++ standard library |
---|
82 | exceptions. |
---|
83 | */ |
---|
84 | class IO_error : public std::runtime_error |
---|
85 | { |
---|
86 | public: |
---|
87 | /** |
---|
88 | \brief Constructor to create an exception with a message. |
---|
89 | */ |
---|
90 | inline IO_error(std::string message) throw() |
---|
91 | : std::runtime_error("IO_error: " + message) {} |
---|
92 | }; |
---|
93 | |
---|
94 | }}} // of namespace utility, yat, and theplu |
---|
95 | |
---|
96 | #endif |
---|