forked from AcademySoftwareFoundation/MaterialX
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPyException.cpp
More file actions
32 lines (26 loc) · 749 Bytes
/
PyException.cpp
File metadata and controls
32 lines (26 loc) · 749 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//
// TM & (c) 2017 Lucasfilm Entertainment Company Ltd. and Lucasfilm Ltd.
// All rights reserved. See LICENSE.txt for license.
//
#include <PyMaterialX/PyMaterialX.h>
#include <MaterialXCore/Exception.h>
namespace py = pybind11;
namespace mx = MaterialX;
void bindPyException(py::module& mod)
{
static py::exception<mx::Exception> pyException(mod, "Exception");
py::register_exception_translator(
[](std::exception_ptr errPtr)
{
try
{
if (errPtr != NULL)
std::rethrow_exception(errPtr);
}
catch (const mx::Exception& err)
{
PyErr_SetString(PyExc_LookupError, err.what());
}
}
);
}