2 Permission is granted to use, modify, and / or redistribute at will.
4 This includes removing authorship notices, re-use of code parts in
5 other software (with or without giving credit), and / or creating a
6 commercial product based on it.
8 This permission is not revocable by the author.
10 This software is provided as-is. Use it at your own risk. There is
11 no warranty whatsoever, neither expressed nor implied, and by using
12 this software you accept that the author(s) shall not be held liable
13 for any loss of data, loss of service, or other damages, be they
14 incidental or consequential. Your only option other than accepting
15 this is not to use the software at all.
17 #ifndef _LIGHTLIBCPP_EXCEPTION_HPP
18 #define _LIGHTLIBCPP_EXCEPTION_HPP
22 #include <lightlibc++/compiler.hpp>
28 /** \addtogroup lightlibcpp_18_7 */
33 * \brief Base class for exceptions thrown by the C++ Standard Library
35 * 18.7.1 Class exception
37 * Base class for exceptions thrown by the C++ Standard Library
40 * \brief Basisklasse der Ausnahmen, die von der C++ Standardbibliothek geworfen werden
42 * 18.7.1 Klasse exception
44 * Basisklasse der Ausnahmen, die von der C++ Standardbibliothek geworfen werden
52 * Constructs an object of class exception.
55 * Konstruiert ein Objekt der Klasse exception.
57 inline exception() throw()
63 * Copies an object of class exception.
64 * \param[in] x reference to the object to copy
67 * Kopiert ein Objekt der Klasse exception.
68 * \param[in] x Referenz auf das zu kopierende Objekt
70 inline exception(const exception
& x
) throw()
77 * Copies an object of class exception.
78 * \param[in] x reference to the object to copy
81 * Kopiert ein Objekt der Klasse exception.
82 * \param[in] x Referenz auf das zu kopierende Objekt
84 inline exception
& operator = (const exception
& x
) throw()
92 * Destructs an object of class exception
95 * Zerstört ein Objekt der Klasse exception
97 virtual ~exception() throw();
101 * User-friendly name of the class
102 * \return null-terminated character sequence
105 * Benutzerfreundlicher Name der Klasse
106 * \return nullterminierte Zeichenkette
109 virtual const char* what() const throw();
116 /** \addtogroup lightlibcpp_18_7_2 */
121 * \brief Class thrown by the runtime, when an exception-specification is
124 * 18.7.2.1 Class bad_exception
126 * Class thrown by the runtime, when an exception-specification is violated
129 * \brief Klasse die von der Laufzeit geworfen wird, wenn eine
130 * Ausnahmenspezifikation verletzt wurde
132 * 18.7.2.1 Klasse bad_exception
134 * Klasse die von der Laufzeit geworfen wird, wenn eine
135 * Ausnahmenspezifikation verletzt wurde
138 class bad_exception
: public std::exception
143 * Constructs an object of class bad_exception.
146 * Konstruiert ein Objekt der Klasse bad_exception.
148 inline bad_exception() throw()
154 * Copies an object of class bad_exception.
155 * \param[in] x reference to the object to copy
158 * Kopiert ein Objekt der Klasse bad_exception.
159 * \param[in] x Referenz auf das zu kopierende Objekt
161 inline bad_exception(const bad_exception
& x
) throw()
168 * Destructs an object of class bad_exception
171 * Zerstört ein Objekt der Klasse bad_exception
173 virtual ~bad_exception() throw();
175 virtual const char* what() const throw();
180 * 18.7.2.2 Type unexpected_handler
182 * The type of a handler function to be called by unexpected() when a
183 * function attempts to throw an exception not listed in its
184 * exception-specification.
186 * An unexpected_handler shall not return.
188 * The default unexpected_handler calls terminate().
191 * 18.7.2.2 Typ unexpected_handler
193 * Der Typ einer Handlerfunktion, welche von unexpected() aufgerufen wird,
194 * wenn eine Funktion eine Ausnahme, die nicht in ihrer
195 * Ausnahmenspezifikation angegeben ist, wirft.
197 * Ein unexpected_handler darf die Kontrolle nicht an die aufrufende
198 * Funktion zurückgeben.
200 * Der standardmäßig installierte unexpected_handler ruft terminate() auf.
203 typedef void (*unexpected_handler
)() _LIGHTLIBCPP_NORETURN
;
206 * 18.7.2.3 set_unexpected
209 * The unexpected_handler f becomes the new handler called by unexpected()
210 * \param[in] f a non-null pointer to the new unexpected_handler
211 * \return a pointer to the previous unexpected_handler
214 * Der unexpected_handler f wird der neue Handler, der von unexpected()
216 * \param[in] f ein gültiger Zeiger auf einen unexpected_handler
217 * \return ein Zeiger auf den vorhergehende unexpected_handler
220 unexpected_handler
set_unexpected(unexpected_handler f
) throw();
224 * lightlibc++ extension
226 * Get the current unexpected_handler
227 * \note This function is needed by the C++ exception handling ABI
228 * \return apointer to the current unexpected_handler
231 * lightlibc++ Erweiterung
233 * Gibt einen Zeiger auf momentan installierten unexpected_handler zurück
234 * \note Diese Funktion wird von der C++ Ausnahmebehandlungs-ABI benötigt
235 * \return ein Zeiger auf den momentan installierten unexpected_handler
238 unexpected_handler
__get_unexpected();
241 * 18.6.2.4 unexpected
244 * Called by the implementation when a function exits via an exception not
245 * allowed by its exception-specification. May also be called directly by the
248 * Calls the calls the current unexpected_handler.
251 * Diese Funktion wird vom der Laufzeit aufgerufen, falls eine Funktion eine
252 * Ausnahme, die nicht in ihrer Ausnahmenspezifikation angegeben ist, wirft.
253 * Diese Funktion darf auch direkt aus dem Programm aufgerufen werden.
255 * unexpected() ruft den momentanen unexpected_handler auf.
258 void unexpected() _LIGHTLIBCPP_NORETURN
;
264 /** \addtogroup lightlibcpp_18_7_3 */
269 * 18.7.3.1 Type terminate_handler
271 * The type of a handler function to be called by terminate() when
272 * terminating exception processing.
274 * A terminate_handler shall terminate execution of the program without
275 * returning to the caller.
277 * The default terminate_handler calls abort().
280 * 18.7.3.1 Typ terminate_handler
282 * Der Typ einer Handlerfunktion, welche von terminate() aufgerufen wird,
283 * wenn die Ausnahmebehandlung terminiert wird (durch den standardmäßig
284 * installierten unexpected_handler).
286 * Ein terminate_handler muss das Programm beenden ohne die Kontrolle zum
287 * Aufrufer zurückzugeben
289 * Der standardmäßig installierte terminate_handler ruft abort() auf.
292 typedef void (*terminate_handler
)() _LIGHTLIBCPP_NORETURN
;
295 * 18.7.3.2 set_terminate
298 * The terminate_handler f becomes the new handler called by terminate()
299 * \param[in] f a non-null pointer to the new terminate_handler
300 * \return a pointer to the previous terminate_handler
303 * Der terminate_handler f wird der neue Handler, der von terminate()
305 * \param[in] f ein gültiger Zeiger auf einen terminate_handler
306 * \return ein Zeiger auf den vorhergehende terminate_handler
309 terminate_handler
set_terminate(terminate_handler f
) throw();
313 * lightlibc++ extension
315 * Get the current terminate_handler
316 * \note This function is needed by the C++ exception handling ABI
317 * \return apointer to the current terminate_handler
320 * lightlibc++ Erweiterung
322 * Gibt einen Zeiger auf momentan installierten terminate_handler zurück
323 * \note Diese Funktion wird von der C++ Ausnahmebehandlungs-ABI benötigt
324 * \return ein Zeiger auf den momentan installierten terminate_handler
327 terminate_handler
__get_terminate();
333 * Called by the default unexpected_handler. May also be called directly by
336 * Calls the calls the current terminate_handler.
339 * Diese Funktion wird vom standardmäßig installierten unexpected_handler
340 * aufgerufen. Außerdem darf terminate() auch direkt aus dem Programm
343 * terminate() ruft den momentanen terminate_handler auf.
346 void terminate() _LIGHTLIBCPP_NORETURN
;
352 /** \addtogroup lightlibcpp_18_7 */
355 // TODO: bool uncaught_exception() throw(), implemented by the C++ ABI: Exception Handling patch
357 #ifdef _LIGHTLIBCPP_CPP10
358 // TODO C++1x: typedef \unspec exception_ptr;
359 // TODO C++1x: exception_ptr current_exception();
360 // TODO C++1x: void rethrow_exception(exception_ptr p);
361 // TODO C++1x: template<class E> exception_ptr copy_exception(E e);