exception.hh 1 KB
Newer Older
1 2 3
// Copyright 2010, Florent Lamiraux, Thomas Moulard, LAAS-CNRS.

#ifndef DYNAMIC_GRAPH_PYTHON_EXCEPTION
Guilhem Saurel's avatar
format  
Guilhem Saurel committed
4
#define DYNAMIC_GRAPH_PYTHON_EXCEPTION
5 6 7

/// \brief Catch all exceptions which may be sent when C++ code is
/// called.
Guilhem Saurel's avatar
format  
Guilhem Saurel committed
8 9
#define CATCH_ALL_EXCEPTIONS()                       \
  catch (const std::exception& exc) {                \
Guilhem Saurel's avatar
Guilhem Saurel committed
10
    PyErr_SetString(DGPYERROR, exc.what());          \
Guilhem Saurel's avatar
format  
Guilhem Saurel committed
11 12 13
    return NULL;                                     \
  }                                                  \
  catch (const char* s) {                            \
Guilhem Saurel's avatar
Guilhem Saurel committed
14
    PyErr_SetString(DGPYERROR, s);                   \
Guilhem Saurel's avatar
format  
Guilhem Saurel committed
15 16 17
    return NULL;                                     \
  }                                                  \
  catch (...) {                                      \
Guilhem Saurel's avatar
Guilhem Saurel committed
18
    PyErr_SetString(DGPYERROR, "Unknown exception"); \
Guilhem Saurel's avatar
format  
Guilhem Saurel committed
19 20 21
    return NULL;                                     \
  }                                                  \
  struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n
22

Guilhem Saurel's avatar
format  
Guilhem Saurel committed
23
#endif  //! DYNAMIC_GRAPH_PYTHON_EXCEPTION