src/include/error.h
changeset 490 ceb56ff9d07f
parent 489 afbdf8a3a633
child 491 4804c967543d
equal deleted inserted replaced
0:d08e1810b9ce 1:ef5f7abcb350
     4 #define HUGO_ERROR_H
     4 #define HUGO_ERROR_H
     5 
     5 
     6 //! \file
     6 //! \file
     7 //! \brief Basic error handling (signaling) routines.
     7 //! \brief Basic error handling (signaling) routines.
     8 
     8 
       
     9 #include <exception>
     9 #include <string>
    10 #include <string>
    10 #include <sstream>
    11 #include <sstream>
    11 
    12 
    12 
    13 
    13 namespace hugo {
    14 namespace hugo {
    25   protected:
    26   protected:
    26     std::ostringstream buf;
    27     std::ostringstream buf;
    27   public:
    28   public:
    28     Exception() {}
    29     Exception() {}
    29     explicit Exception(const std::string &s) { buf << s; }
    30     explicit Exception(const std::string &s) { buf << s; }
    30     Exception(const Exception &e) { buf << e.buf.str(); }
    31     Exception(const Exception &e) : std::exception() {
       
    32       buf << e.buf.str();
       
    33     }
    31     virtual ~Exception() throw() {}
    34     virtual ~Exception() throw() {}
    32     
    35     
    33     virtual const char* what() const throw() {
    36     virtual const char* what() const throw() {
    34       return buf.str().c_str();
    37       return buf.str().c_str();
    35     }
    38     }
    54    * \todo Is this the right place for this? It should be used only in
    57    * \todo Is this the right place for this? It should be used only in
    55    * modules under development.
    58    * modules under development.
    56    */
    59    */
    57 
    60 
    58 # define FIXME(msg) \
    61 # define FIXME(msg) \
    59     do { throw ::hugo::Exception("FIXME: " msg) << " (in: "    \
    62     do { throw ::hugo::Exception() << "FIXME: " msg " (in: "    \
    60       << __FILE__ << ", " << __LINE__ << ")";                  \
    63       __FILE__ ", " << __LINE__ << ")";                         \
    61     } while(false)
    64     } while(false)
    62 
    65 
    63 }
    66 }
    64 #endif // HUGO_ERROR_H
    67 #endif // HUGO_ERROR_H