All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ntesukiExceptions.h
Go to the documentation of this file.
1 /* ntesukiExceptions
2  */
3 #ifndef OSL_NTESUKI_EXCEPTIONS
4 #define OSL_NTESUKI_EXCEPTIONS
5 #include <iostream>
6 #include <stdexcept>
7 
8 #ifndef NDEBUG
9 # define ntesuki_assert(assertion)\
10 if (!(assertion))\
11  throw DfpnError("assertion failed", __FILE__, __LINE__);
12 #else
13 #define ntesuki_assert(assertion)
14 #endif
15 
16 #ifndef NDEBUG
17 #define TRY_DFPN \
18 try\
19 {\
20 
21 #define CATCH_DFPN \
22 }\
23 catch (DfpnError err)\
24 {\
25  ntesuki_assert(false);\
26 }
27 #else
28 #define TRY_DFPN
29 #define CATCH_DFPN
30 #endif
31 
32 namespace osl
33 {
34  namespace ntesuki
35  {
39  struct DfpnError : std::runtime_error
40  {
41  DfpnError(const char *message,
42  const char *filename,
43  int linenum) : std::runtime_error(message)
44  {
45  std::cerr << message
46  << "\n\tin " << filename
47  << " line " << linenum << "\n";
48  }
49  };
50  }// ntesuki
51 }//osl
52 
53 #endif /* OSL_NTESUKI_EXCEPTIONS */
54 // ;;; Local Variables:
55 // ;;; mode:c++
56 // ;;; c-basic-offset:2
57 // ;;; End: