2 * src/lemon/error.h - Part of LEMON, a generic C++ optimization library
4 * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
5 * (Egervary Combinatorial Optimization Research Group, EGRES).
7 * Permission to use, modify and distribute this software is granted
8 * provided that this copyright notice appears in all copies. For
9 * precise terms see the accompanying LICENSE file.
11 * This software is provided "AS IS" with no warranty of any kind,
12 * express or implied, and with no claim as to its suitability for any
22 //! \brief Basic error handling (signaling) routines.
32 * \brief Generic exception class.
34 * \todo Do we need this?
36 * \todo Don't we need different kind of exceptions for different kind
38 * Shouldn't we use \<stdexcept\> instead?
40 class Exception : public std::exception {
42 std::ostringstream buf;
45 explicit Exception(const std::string &s) { buf << s; }
46 Exception(const Exception &e) : std::exception() {
49 virtual ~Exception() throw() {}
51 virtual const char* what() const throw() {
52 return buf.str().c_str();
56 Exception& operator<<(T const& t) { buf << t; return *this; }
60 * \brief Generic error signaling function.
62 * \todo Do we really need this? Is it helpful?
64 inline void fault(const std::string &msg) {
69 * \brief Macro for mark not yet implemented features.
71 * \todo Is this the right place for this? It should be used only in
72 * modules under development.
76 do { throw ::lemon::Exception() << "FIXME: " msg " (in: " \
77 __FILE__ ", " << __LINE__ << ")"; \
81 #endif // LEMON_ERROR_H