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
26namespace 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 */
35OutOfMemoryException::OutOfMemoryException(const char *format, ...) noexcept : Exception()
36{
37 va_list va;
38 va_start(va, format);
39 append_va(format, va);
40 va_end(va);
41}
42
43/** Constructor.
44 * Message simply is "Out of memory"
45 */
47{
48}
49
50/** @class InterruptedException <core/exceptions/system.h>
51 * The current system call has been interrupted (for instance by a signal).
52 * Throw this exception if you use libc functions which return EINTR or store
53 * EINTR in errnum.
54 * @ingroup Exceptions
55 */
56/** Constructor */
57InterruptedException::InterruptedException() noexcept : Exception("Interrupted system call")
58{
59}
60
61/** Constructor
62 * @param format message format string
63 */
64InterruptedException::InterruptedException(const char *format, ...) noexcept : Exception()
65{
66 va_list va;
67 va_start(va, format);
68 append_va(format, va);
69 va_end(va);
70}
71
72/** @class TimeoutException <core/exceptions/system.h>
73 * The current system call has timed out before completion.
74 * Throw this exception for instance when a timed wait on a WaitCondition
75 * timed out.
76 * @ingroup Exceptions
77 */
78/** Constructor */
79TimeoutException::TimeoutException() noexcept : Exception("Timeout reached.")
80{
81}
82
83/** Constructor
84 * @param format message format string
85 */
86TimeoutException::TimeoutException(const char *format, ...) noexcept : Exception()
87{
88 va_list va;
89 va_start(va, format);
90 append_va(format, va);
91 va_end(va);
92}
93
94/** @class CouldNotOpenFileException <core/exceptions/system.h>
95 * File could not be opened.
96 * The file could not be opened. Optional error number and message describe the
97 * problem in more detai.
98 * @ingroup Exceptions
99 */
100
101/** Constructor with error number.
102 * @param filename name of file which could not be opened
103 * @param errnum error number
104 * @param additional_msg optional additional message
105 */
107 int errnum,
108 const char *additional_msg) noexcept
109: Exception(errnum,
110 "Could not open file '%s' %s%s%s",
111 filename,
112 (additional_msg) ? "(" : "",
113 (additional_msg) ? additional_msg : "",
114 (additional_msg) ? ")" : "")
115{
116}
117
118/** Constructor with error number.
119 * @param filename name of file which could not be opened
120 * @param additional_msg optional additional message
121 */
123 const char *additional_msg) noexcept
124: Exception("Could not open file '%s' %s%s%s",
125 filename,
126 (additional_msg) ? "(" : "",
127 (additional_msg) ? additional_msg : "",
128 (additional_msg) ? ")" : "")
129{
130}
131
132/** @class FileReadException <core/exceptions/system.h>
133 * File could not be read.
134 * The file could not be read. Optional error number and message describe the
135 * problem in more detail.
136 * @ingroup Exceptions
137 */
138
139/** Constructor with error number.
140 * @param filename name of file which could not be read
141 * @param errnum error number
142 * @param additional_msg optional additional message
143 */
145 int errnum,
146 const char *additional_msg) noexcept
147: Exception(errnum,
148 "Could not read from file '%s' %s%s%s",
149 filename,
150 (additional_msg) ? "(" : "",
151 (additional_msg) ? additional_msg : "",
152 (additional_msg) ? ")" : "")
153{
154}
155
156/** Constructor with error number.
157 * @param filename name of file which could not be read
158 * @param additional_msg optional additional message
159 */
160FileReadException::FileReadException(const char *filename, const char *additional_msg) noexcept
161: Exception("Could not read from file '%s' %s%s%s",
162 filename,
163 (additional_msg) ? "(" : "",
164 (additional_msg) ? additional_msg : "",
165 (additional_msg) ? ")" : "")
166{
167}
168
169/** @class FileWriteException <core/exceptions/system.h>
170 * Could not write to file.
171 * Writing to a file failed. Optional error number and message describe the
172 * problem in more detail.
173 * @ingroup Exceptions
174 */
175
176/** Constructor with error number.
177 * @param filename name of file which could not be written to
178 * @param errnum error number
179 * @param additional_msg optional additional message
180 */
182 int errnum,
183 const char *additional_msg) noexcept
184: Exception(errnum,
185 "Could not write to file '%s' %s%s%s",
186 filename,
187 (additional_msg) ? "(" : "",
188 (additional_msg) ? additional_msg : "",
189 (additional_msg) ? ")" : "")
190{
191}
192
193/** Constructor with error number.
194 * @param filename name of file which could not be written
195 * @param additional_msg optional additional message
196 */
197FileWriteException::FileWriteException(const char *filename, const char *additional_msg) noexcept
198: Exception("Could not write to file '%s' %s%s%s",
199 filename,
200 (additional_msg) ? "(" : "",
201 (additional_msg) ? additional_msg : "",
202 (additional_msg) ? ")" : "")
203{
204}
205
206} // end namespace fawkes
CouldNotOpenFileException(const char *filename, int errnum, const char *additional_msg=0) noexcept
Constructor with error number.
Definition: system.cpp:106
Base class for exceptions in Fawkes.
Definition: exception.h:36
void append_va(const char *format, va_list va) noexcept
Append messages to the message list.
Definition: exception.cpp:353
FileReadException(const char *filename, int errnum, const char *additional_msg=0) noexcept
Constructor with error number.
Definition: system.cpp:144
FileWriteException(const char *filename, int errnum, const char *additional_msg=0) noexcept
Constructor with error number.
Definition: system.cpp:181
InterruptedException() noexcept
Constructor.
Definition: system.cpp:57
OutOfMemoryException() noexcept
Constructor.
Definition: system.cpp:46
TimeoutException() noexcept
Constructor.
Definition: system.cpp:79
Fawkes library namespace.