1.1 --- a/src/hugo/attic/error.h Wed Sep 29 14:12:26 2004 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,82 +0,0 @@
1.4 -/* -*- C++ -*-
1.5 - * src/hugo/error.h - Part of HUGOlib, 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 HUGO_ERROR_H
1.21 -#define HUGO_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 hugo {
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 - Exception& operator<<(std::string const& s) { buf << s; return *this; }
1.59 - Exception& operator<<(char const *s) { buf << s; return *this; }
1.60 - Exception& operator<<(int i) { buf << i; return *this; }
1.61 - };
1.62 -
1.63 - /**
1.64 - * \brief Generic error signaling function.
1.65 - *
1.66 - * \todo Do we really need this? Is it helpful?
1.67 - */
1.68 - inline void fault(const std::string &msg) {
1.69 - throw Exception(msg);
1.70 - }
1.71 -
1.72 - /**
1.73 - * \brief Macro for mark not yet implemented features.
1.74 - *
1.75 - * \todo Is this the right place for this? It should be used only in
1.76 - * modules under development.
1.77 - */
1.78 -
1.79 -# define FIXME(msg) \
1.80 - do { throw ::hugo::Exception() << "FIXME: " msg " (in: " \
1.81 - __FILE__ ", " << __LINE__ << ")"; \
1.82 - } while(false)
1.83 -
1.84 -}
1.85 -#endif // HUGO_ERROR_H