Correct propagating nvbench_main exceptions to Python

python examples/cpu_only.py --run-once -d 0 --output foo.md

used to trip SystemError, returned a result with an exception set.

It now returns a clean NVBenchmarkError exception.
This commit is contained in:
Oleksandr Pavlyk
2025-07-21 13:31:34 -05:00
parent 9ab642cf69
commit e426368485

View File

@@ -192,16 +192,14 @@ public:
}
catch (const std::exception &e)
{
std::stringstream ss;
ss << "Caught exception while running benchmarks: ";
ss << e.what();
const std::string &exc_message = ss.str();
const std::string &exc_message = e.what();
py::set_error(benchmark_exc, exc_message.c_str());
throw py::error_already_set();
}
catch (...)
{
py::set_error(benchmark_exc, "Caught unknown exception in nvbench_main");
throw py::error_already_set();
}
}
};