mirror of
https://github.com/johndoe6345789/SDL3CPlusPlus.git
synced 2026-04-25 06:04:57 +00:00
32 lines
712 B
C++
32 lines
712 B
C++
//
|
|
// Copyright Contributors to the MaterialX Project
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
|
|
#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());
|
|
}
|
|
}
|
|
);
|
|
|
|
} |