10 #define EXCEPTIONS_HH_
13 #include <boost/exception/all.hpp>
34 #define THROW(whole_exception_expr) BOOST_THROW_EXCEPTION( whole_exception_expr)
55 class ExceptionBase :
public virtual std::exception,
public virtual boost::exception
70 virtual void print_info(std::ostringstream &out)
const=0;
76 virtual const char *
what ()
const throw ();
135 #define DECLARE_EXCEPTION( ExcName, Format) \
136 struct ExcName : public virtual ::ExceptionBase { \
137 virtual void print_info(std::ostringstream &out) const { \
138 using namespace internal; \
139 ::internal::ExcStream estream(out, *this); \
143 virtual ~ExcName() throw () {} \
173 #define TYPEDEF_ERR_INFO(EI_Type, Type) typedef EI< struct EI_Type##_TAG, Type > EI_Type
190 template<
class Tag,
class Type>
191 class EI :
public boost::error_info< Tag, Type > {
193 typedef typename boost::error_info< Tag, Type>
ErrorInfo;
233 template <
class Type>
240 inline const Type &
value()
const {
return (*
x_);}
247 std::ostream&
operator<<
250 if (value.is_null())
return (stream <<
"NO_VALUE");
251 else if (value.is_quoted())
return (stream <<
"'" << value.value() <<
"'");
252 else return (stream << value.value() );
291 template <
class Tag,
class Type,
class Func>
292 internal::ExcStream & operator<<(internal::ExcStream & estream, typename EI<Tag, Type>::template lambda<Func>
const & lambda_func)
309 DECLARE_EXCEPTION( ExcXprintfMsg, << EI_XprintfHeader::val << EI_XprintfMessage::val);
318 template <
class Tag,
class Type>
321 ( ptr(es.
exc_), false );
327 template <
class Tag,
class Type>
330 ( ptr(es.
exc_), true );
335 template <
class Tag,
class Type>
338 Type
const * val_ptr = boost::get_error_info< ErrorInfo > (e);
341 std::cerr <<
"------------------------------------------------------------------------------\n";
342 std::cerr <<
" Fatal Error - dereferencing null pointer when formating an exception message.\n";
343 std::cerr <<
"------------------------------------------------------------------------------\n";
344 std::cerr <<
"** Diagnosting Informations **\n";
345 std::cerr << boost::diagnostic_information_what( e );
352 template <
class Tag,
class Type>
354 {
return boost::get_error_info< ErrorInfo > (e); }