exc.hpp
Go to the documentation of this file.
1
5#include <exception> // std::exception
6#ifndef UUID_274DA366004E11DCB1DDFE2E56D89593
7#include <boost/exception/exception.hpp> // boost::exception
8#endif
9#ifndef UUID_8D22C4CA9CC811DCAA9133D256D89593
10#include <boost/exception/info.hpp> // boost::throw_{function,file,line}
11#endif
12
13#ifndef OPM_VERTEQ_VISIBILITY_INCLUDED
15#endif
16#if defined (opmverteq_EXPORTS)
17# define OPM_VERTEQ_PUBLIC SYMBOL_IS_EXPORTED
18#else
19# define OPM_VERTEQ_PUBLIC SYMBOL_IS_IMPORTED
20#endif
21#define OPM_VERTEQ_PRIVATE SYMBOL_IS_LOCALDEF
22
23// enable printf-style attribute for MSVC
24#ifdef _MSC_VER
25# if _MSC_VER >= 1400
26# define _USE_ATTRIBUTES_FOR_SAL 1
27# include <sal.h>
28# endif
29#endif
30
31namespace Opm {
32namespace Exc {
48 : public virtual std::exception
49 , public virtual boost::exception {
50
58 virtual Base& operator () (
59#ifdef _MSC_VER
60# if _MSC_VER >= 1400
61 __format_string
62# endif
63#endif
64 char const* fmt, ...)
65 // there is an implicit this parameter at the start, so the format
66 // string is the second parameter, and the variable argument list
67 // starts with the third.
68#ifdef __GNUC__
69 __attribute__ ((format (printf, 2, 3)))
70#endif
71 ;
72
77 virtual char const* what () const throw ();
78};
79
85std::string OPM_VERTEQ_PUBLIC diag_what (std::exception const& ex);
86
91#ifdef DEBUG
92// const_cast is necessary because the operator<< returns a
93// const, and we may want it mutable to add more information
94 #define OPM_EXC const_cast <Opm::Exc::Base&>(Opm::Exc::Base ()\
95 << ::boost::throw_function (BOOST_CURRENT_FUNCTION)\
96 << ::boost::throw_file (__FILE__)\
97 << ::boost::throw_line (static_cast <int> (__LINE__))\
98)
99#else
100 #define OPM_EXC Opm::Exc::Base ()
101#endif
102
103#define OPM_WHAT(ex) Opm::Exc::diag_what (ex)
104
105} /* namespace Opm::Exc */
106} /* namespace Opm */
#define OPM_VERTEQ_PUBLIC
Definition: exc.hpp:19
std::string OPM_VERTEQ_PUBLIC diag_what(std::exception const &ex)
Retrieve information about the code that failed.
Definition: opmfwd.hpp:15
Definition: exc.hpp:49
virtual char const * what() const
Message created at the throw-site about the error.