【发布时间】:2020-04-07 15:11:10
【问题描述】:
我正在制作一个游戏引擎,我已经为脚本编写了一个 c++ 热重载,但我遇到了一个问题。问题是,如果用户犯了错误,脚本崩溃了,引擎也会崩溃。 有 2 个项目,第一个是 exe(引擎),另一个是 dll,用户可以修改和添加任何他想要的脚本。
是否可以在 dll 函数中捕获错误以使我的引擎也不会崩溃?
类似这样的:
auto item = current_scripts.begin();
for (; item != current_scripts.end(); ++item) {
if (*item != nullptr) {
try {
// I would like to be able to catch all possible errors/exceptions the user might do
throw (*item)->Update();
// this is calling a dll function that the exe does not know what is doing
}
catch(...) {
LOG("Error In Update");
}
}
}
【问题讨论】:
标签: c++ exception dll game-engine hot-reload