summaryrefslogtreecommitdiffstats
path: root/ml/dlib/dlib/python/pyassert.h
blob: 80939f501f9a9ab89f2be14eeaafeee67779c58a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Copyright (C) 2013  Davis E. King (davis@dlib.net)
// License: Boost Software License   See LICENSE.txt for the full license.
#ifndef DLIB_PYaSSERT_Hh_
#define DLIB_PYaSSERT_Hh_

#include <pybind11/pybind11.h>

#define pyassert(_exp,_message)                                             \
    {if ( !(_exp) )                                                         \
    {                                                                       \
        namespace py = pybind11;                                            \
        PyErr_SetString( PyExc_ValueError, _message );                      \
        throw py::error_already_set();                                      \
    }}

#endif // DLIB_PYaSSERT_Hh_