Skip to content

Commit f861c4a

Browse files
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.
1 parent ceda9f9 commit f861c4a

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

python/src/py_nvbench.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,16 +192,14 @@ class GlobalBenchmarkRegistry
192192
}
193193
catch (const std::exception &e)
194194
{
195-
std::stringstream ss;
196-
ss << "Caught exception while running benchmarks: ";
197-
ss << e.what();
198-
199-
const std::string &exc_message = ss.str();
195+
const std::string &exc_message = e.what();
200196
py::set_error(benchmark_exc, exc_message.c_str());
197+
throw py::error_already_set();
201198
}
202199
catch (...)
203200
{
204201
py::set_error(benchmark_exc, "Caught unknown exception in nvbench_main");
202+
throw py::error_already_set();
205203
}
206204
}
207205
};

0 commit comments

Comments
 (0)