aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/udfs/common/python/bindings/py_errors.h
blob: 2306b47bb952fb0d605d1a4c084cb7105853dc64 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#pragma once

#include <util/generic/fwd.h>

namespace NPython {

TString GetLastErrorAsString();

#define PY_TRY try

#define PY_CATCH(ErrorValue) \
    catch (const yexception& e) { \
        PyErr_SetString(PyExc_RuntimeError, e.what()); \
        return ErrorValue; \
    }

#define PY_ENSURE(condition, message) \
    do { \
        if (Y_UNLIKELY(!(condition))) { \
            throw yexception() << message; \
        } \
    } while (0)

} // namspace NPython