Program listing for file kernel/src/utils/SiconosException.hpp#
Return to documentation for this file
1#ifndef __SICONOSEXCEPTION_HPP__
2#define __SICONOSEXCEPTION_HPP__
3
4#include <exception>
5#include <boost/throw_exception.hpp>
6#include <boost/exception/diagnostic_information.hpp>
7#include <cstring>
8#include <iostream>
9#include <errno.h>
10
11
12
13namespace Siconos
14{
15
16
17
18 class exception : public virtual std::exception, public virtual boost::exception
19 {
20
21 public:
22
23
24
25
26 typedef boost::error_info<struct tag_errno_code,int> errno_code;
27 typedef boost::error_info<struct tag_errno_description,const char *> errno_description;
28 typedef boost::error_info<struct message, std::string> extra_message;
29
30 static inline void process()
31 {
32 std::cerr << boost::current_exception_diagnostic_information(true) << std::endl;
33 }
34
35
36 static inline void process(Siconos::exception& e)
37 {
38 std::cerr << boost::diagnostic_information(e, true) << std::endl;
39 }
40
41 };
42
43}
44
45
46#define THROW_EXCEPTION(X) BOOST_THROW_EXCEPTION(Siconos::exception() << Siconos::exception::extra_message(X) << Siconos::exception::errno_code(errno) <<Siconos::exception::errno_description(std::strerror(errno)));
47
48#endif