1.1 --- a/src/lemon/error.h Thu Feb 03 19:24:42 2005 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,81 +0,0 @@
1.4 -/* -*- C++ -*-
1.5 - * src/lemon/error.h - Part of LEMON, a generic C++ optimization library
1.6 - *
1.7 - * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
1.8 - * (Egervary Combinatorial Optimization Research Group, EGRES).
1.9 - *
1.10 - * Permission to use, modify and distribute this software is granted
1.11 - * provided that this copyright notice appears in all copies. For
1.12 - * precise terms see the accompanying LICENSE file.
1.13 - *
1.14 - * This software is provided "AS IS" with no warranty of any kind,
1.15 - * express or implied, and with no claim as to its suitability for any
1.16 - * purpose.
1.17 - *
1.18 - */
1.19 -
1.20 -#ifndef LEMON_ERROR_H
1.21 -#define LEMON_ERROR_H
1.22 -
1.23 -//! \ingroup misc
1.24 -//! \file
1.25 -//! \brief Basic error handling (signaling) routines.
1.26 -
1.27 -#include <exception>
1.28 -#include <string>
1.29 -#include <sstream>
1.30 -
1.31 -
1.32 -namespace lemon {
1.33 -
1.34 - /**
1.35 - * \brief Generic exception class.
1.36 - *
1.37 - * \todo Do we need this?
1.38 - *
1.39 - * \todo Don't we need different kind of exceptions for different kind
1.40 - * of errors?
1.41 - * Shouldn't we use \<stdexcept\> instead?
1.42 - */
1.43 - class Exception : public std::exception {
1.44 - protected:
1.45 - std::ostringstream buf;
1.46 - public:
1.47 - Exception() {}
1.48 - explicit Exception(const std::string &s) { buf << s; }
1.49 - Exception(const Exception &e) : std::exception() {
1.50 - buf << e.buf.str();
1.51 - }
1.52 - virtual ~Exception() throw() {}
1.53 -
1.54 - virtual const char* what() const throw() {
1.55 - return buf.str().c_str();
1.56 - }
1.57 -
1.58 - template <typename T>
1.59 - Exception& operator<<(T const& t) { buf << t; return *this; }
1.60 - };
1.61 -
1.62 - /**
1.63 - * \brief Generic error signaling function.
1.64 - *
1.65 - * \todo Do we really need this? Is it helpful?
1.66 - */
1.67 - inline void fault(const std::string &msg) {
1.68 - throw Exception(msg);
1.69 - }
1.70 -
1.71 - /**
1.72 - * \brief Macro for mark not yet implemented features.
1.73 - *
1.74 - * \todo Is this the right place for this? It should be used only in
1.75 - * modules under development.
1.76 - */
1.77 -
1.78 -# define FIXME(msg) \
1.79 - do { throw ::lemon::Exception() << "FIXME: " msg " (in: " \
1.80 - __FILE__ ", " << __LINE__ << ")"; \
1.81 - } while(false)
1.82 -
1.83 -}
1.84 -#endif // LEMON_ERROR_H