Fawkes API  Fawkes Development Version
system.cpp
1 
2 /***************************************************************************
3  * system.cpp - basic system exceptions
4  *
5  * Generated: Sun Oct 29 14:28:17 2006
6  * Copyright 2006 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #include <core/exceptions/system.h>
25 
26 namespace fawkes {
27 
28 /** @class OutOfMemoryException <core/exceptions/system.h>
29  * System ran out of memory and desired operation could not be fulfilled.
30  * @ingroup Exceptions
31  */
32 /** Constructor
33  * @param format message format string
34  */
35 OutOfMemoryException::OutOfMemoryException(const char *format, ...) throw()
36  : Exception()
37 {
38  va_list va;
39  va_start(va, format);
40  append_va(format, va);
41  va_end(va);
42 }
43 
44 
45 /** Constructor.
46  * Message simply is "Out of memory"
47  */
49  : Exception("Out of memory")
50 {
51 }
52 
53 
54 /** @class InterruptedException <core/exceptions/system.h>
55  * The current system call has been interrupted (for instance by a signal).
56  * Throw this exception if you use libc functions which return EINTR or store
57  * EINTR in errnum.
58  * @ingroup Exceptions
59  */
60 /** Constructor */
62  : Exception("Interrupted system call")
63 {
64 }
65 
66 
67 /** Constructor
68  * @param format message format string
69  */
70 InterruptedException::InterruptedException(const char *format, ...) throw()
71  : Exception()
72 {
73  va_list va;
74  va_start(va, format);
75  append_va(format, va);
76  va_end(va);
77 }
78 
79 
80 /** @class TimeoutException <core/exceptions/system.h>
81  * The current system call has timed out before completion.
82  * Throw this exception for instance when a timed wait on a WaitCondition
83  * timed out.
84  * @ingroup Exceptions
85  */
86 /** Constructor */
88  : Exception("Timeout reached.")
89 {
90 }
91 
92 
93 /** Constructor
94  * @param format message format string
95  */
96 TimeoutException::TimeoutException(const char *format, ...) throw()
97  : Exception()
98 {
99  va_list va;
100  va_start(va, format);
101  append_va(format, va);
102  va_end(va);
103 }
104 
105 
106 /** @class CouldNotOpenFileException <core/exceptions/system.h>
107  * File could not be opened.
108  * The file could not be opened. Optional error number and message describe the
109  * problem in more detai.
110  * @ingroup Exceptions
111  */
112 
113 /** Constructor with error number.
114  * @param filename name of file which could not be opened
115  * @param errnum error number
116  * @param additional_msg optional additional message
117  */
119  const char *additional_msg) throw()
120  : Exception(errnum, "Could not open file '%s' %s%s%s", filename,
121  (additional_msg) ? "(" : "", (additional_msg) ? additional_msg : "",
122  (additional_msg) ? ")" : "")
123 {
124 }
125 
126 
127 /** Constructor with error number.
128  * @param filename name of file which could not be opened
129  * @param additional_msg optional additional message
130  */
132  const char *additional_msg) throw()
133  : Exception("Could not open file '%s' %s%s%s", filename,
134  (additional_msg) ? "(" : "", (additional_msg) ? additional_msg : "",
135  (additional_msg) ? ")" : "")
136 {
137 }
138 
139 
140 /** @class FileReadException <core/exceptions/system.h>
141  * File could not be read.
142  * The file could not be read. Optional error number and message describe the
143  * problem in more detail.
144  * @ingroup Exceptions
145  */
146 
147 /** Constructor with error number.
148  * @param filename name of file which could not be read
149  * @param errnum error number
150  * @param additional_msg optional additional message
151  */
152 FileReadException::FileReadException(const char *filename, int errnum,
153  const char *additional_msg) throw()
154  : Exception(errnum, "Could not read from file '%s' %s%s%s", filename,
155  (additional_msg) ? "(" : "", (additional_msg) ? additional_msg : "",
156  (additional_msg) ? ")" : "")
157 {
158 }
159 
160 
161 /** Constructor with error number.
162  * @param filename name of file which could not be read
163  * @param additional_msg optional additional message
164  */
166  const char *additional_msg) throw()
167  : Exception("Could not read from file '%s' %s%s%s", filename,
168  (additional_msg) ? "(" : "", (additional_msg) ? additional_msg : "",
169  (additional_msg) ? ")" : "")
170 {
171 }
172 
173 
174 /** @class FileWriteException <core/exceptions/system.h>
175  * Could not write to file.
176  * Writing to a file failed. Optional error number and message describe the
177  * problem in more detail.
178  * @ingroup Exceptions
179  */
180 
181 /** Constructor with error number.
182  * @param filename name of file which could not be written to
183  * @param errnum error number
184  * @param additional_msg optional additional message
185  */
186 FileWriteException::FileWriteException(const char *filename, int errnum,
187  const char *additional_msg) throw()
188  : Exception(errnum, "Could not write to file '%s' %s%s%s", filename,
189  (additional_msg) ? "(" : "", (additional_msg) ? additional_msg : "",
190  (additional_msg) ? ")" : "")
191 {
192 }
193 
194 
195 /** Constructor with error number.
196  * @param filename name of file which could not be written
197  * @param additional_msg optional additional message
198  */
200  const char *additional_msg) throw()
201  : Exception("Could not write to file '%s' %s%s%s", filename,
202  (additional_msg) ? "(" : "", (additional_msg) ? additional_msg : "",
203  (additional_msg) ? ")" : "")
204 {
205 }
206 
207 
208 } // end namespace fawkes
Fawkes library namespace.
Exception()
Constructor for subclasses.
Definition: exception.cpp:257
TimeoutException()
Constructor.
Definition: system.cpp:87
FileWriteException(const char *filename, int errnum, const char *additional_msg=0)
Constructor with error number.
Definition: system.cpp:186
OutOfMemoryException()
Constructor.
Definition: system.cpp:48
Base class for exceptions in Fawkes.
Definition: exception.h:36
FileReadException(const char *filename, int errnum, const char *additional_msg=0)
Constructor with error number.
Definition: system.cpp:152
void append_va(const char *format, va_list va)
Append messages to the message list.
Definition: exception.cpp:361
InterruptedException()
Constructor.
Definition: system.cpp:61
CouldNotOpenFileException(const char *filename, int errnum, const char *additional_msg=0)
Constructor with error number.
Definition: system.cpp:118