Introduced FileSystem and Out classes
[openstranded.git] / src / error.hh
blobc1b1ea162020b423b899a5dae3fb80cd936fecf5
1 /*
2 * This file includes global error routines used throughout OpenStranded
4 * Copyright (C) 2008 Hermann Walth
6 * This file is part of OpenStranded
8 * OpenStranded is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
13 * OpenStranded is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with OpenStranded. If not, see <http://www.gnu.org/licenses/>.
22 #ifndef STRANDED_ERROR_HH
23 #define STRANDED_ERROR_HH
25 #include <iostream>
26 #include <string>
27 #include <exception>
29 /**
30 * The StrandedException base class.
31 * OpenStranded uses a classical Warning - Error - Fatal exception
32 * level scheme.
33 * You should use the following classes instead of their StrandedException
34 * base class.
35 * NOTE: Implementation of warnings through exceptions is somewhat difficult,
36 * for you will most probably want to continue your function without disruption
37 * after throwing a Warning, exceptions will, however, always break out of the
38 * function.
39 * Therefore you should not throw this exception if there is another
40 * approach to this problem.
41 * @see StrandedWarning
42 * @see StrandedError
43 * @see StrandedFatal
45 class StrandedException: public std::exception
47 private:
48 /**
49 * The error message.
51 std::string message;
53 public:
54 /**
55 * The constructor.
56 * @param message The error message
58 StrandedException (const char* message);
60 /**
61 * The constructor.
62 * @param message The error message
64 StrandedException (const std::string& message);
66 /**
67 * The destructor.
69 ~StrandedException () throw ();
71 /**
72 * This is a virtual method of the std::exception class
73 * @return The error message
75 const char*
76 what () throw ();
78 /**
79 * Print the error message.
81 virtual void
82 print ();
87 /**
88 * This class defines an Exception with the "Warning" level.
89 * Consider the comments on the StrandedException base class.
90 * @see StrandedException
92 class StrandedWarning: public StrandedException
94 public:
95 /**
96 * The constructor.
97 * @param message The error message
99 StrandedWarning (const char* message);
102 * The constructor.
103 * @param message The error message
105 StrandedWarning (const std::string& message);
108 * Print the error message.
109 * This method will print the error message preceded by an
110 * indicator of the error level.
112 void
113 print ();
118 * This class defines an Exception with the "Error" level.
119 * Consider the comments on the StrandedException base class.
120 * @see StrandedException
122 class StrandedError: public StrandedException
124 public:
126 * The constructor.
127 * @param message The error message
129 StrandedError (const char* message);
132 * The constructor.
133 * @param message The error message
135 StrandedError (const std::string& message);
138 * Print the error message.
139 * This method will print the error message preceded by an
140 * indicator of the error level.
142 void
143 print ();
148 * This class defines an Exception with the "Fatal" level.
149 * Consider the comments on the StrandedException base class.
150 * @see StrandedException
152 class StrandedFatal: public StrandedException
154 public:
156 * The constructor.
157 * @param message The error message
159 StrandedFatal (const char* message);
162 * The constructor.
163 * @param message The error message
165 StrandedFatal (const std::string& message);
168 * Print the error message.
169 * This method will print the error message preceded by an
170 * indicator of the error level.
172 void
173 print ();
176 #endif /* STRANDED_ERROR_HH */