- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在尝试将 lua 嵌入到我的游戏引擎中。直到现在一切都很好。我开始注册函数以与游戏引擎交互(例如 move_object(id, x, y)),并且注册工作正常。接下来,我尝试像这样使用它:
handlers={}
handlers["update"] = function(objId)
-- print(objId)
move_object(objId, 0, 0)
end
这给了我一个来自 luabind 的“运行时错误”异常。我到处搜索,根据互联网(和 luabind 源),错误消息应该仍然在 lua 堆栈的顶部。我 try catch luabind::error,并像这样打印堆栈的顶部:
std::cout << "error: lua: " << lua_tostring(exc.state(), -1) << std::endl;
像这样:
std::cout << "error: lua: " << luabind::object(luabind::from_stack(exc.state(), -1)) << std::endl
并且都打印这个:
error: lua: update
我假设这只是我从处理程序表调用更新函数时推送的最后一个值。这个值应该已经被覆盖,在遇到错误时,用详细的错误字符串,对吗?根据 class error
定义处的 luabind 源文件“error.hpp”:
// this exception usually means that the lua function you called
// from C++ failed with an error code. You will have to
// read the error code from the top of the lua stack
// the reason why this exception class doesn't contain
// the message itself is that std::string's copy constructor
// may throw, if the copy constructor of an exception that is
// being thrown throws another exception, terminate will be called
// and the entire application is killed.
我相信我的 lua 代码的问题实际上是我的 move_object 函数的注册(更新函数运行。我知道这一点,因为我之前没有注释掉那个 print 调用),但是如果没有更好的错误信息我不能确定!哈哈
我修正了这个错误,如果它有任何帮助的话。我是这样定义 move_object 函数的:
luabind::module(m_L)[
luabind::def("move_object", &ScriptEntityManager::move_object)
];
但显然,您不能使用 luabind 将静态成员函数定义为常规函数。我将其更改为(使 move_object
成为 C++ 中的常规全局函数):
luabind::module(m_L)[
luabind::def("move_object", move_object)
];
我不知道这是否有助于解决最初的问题,但我认为提供更多信息不会有什么坏处! :)
最佳答案
我在捕获 luabind 异常时也得到错误消息的错误值。我通过设置 luabind (set_pcall_callback) 使用的错误处理程序解决了这个问题,以便它打印错误(和调用堆栈),这发生在异常被抛出之前。这样对我来说效果很好。
但是如果有人真的知道为什么在捕获异常时栈顶不包含错误信息,我也很感兴趣:-)
这是我使用的错误处理程序,以防它可以帮助某人(其中“print”是一些可以记录 std::string 的自定义函数):
int luabindErrorHandler( lua_State* L )
{
// log the error message
luabind::object msg( luabind::from_stack( L, -1 ) );
std::ostringstream str;
str << "lua> run-time error: " << msg;
print( str.str() );
// log the callstack
std::string traceback = luabind::call_function<std::string>( luabind::globals(L)["debug"]["traceback"] );
traceback = std::string( "lua> " ) + traceback;
print( traceback.c_str() );
// return unmodified error object
return 1;
}
关于c++ - lua+luabind,栈顶没有错误信息, "runtime error"之后,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10768610/
我在内存中有一个 Map 来存储我的对象。我想在内存不足时刷新内存。我现在正在这样做: void add(K key, V value) { if (underPressure()) {
我是 JBPM 的新手。我下载并开始使用 eclipse。然后我安装了 JBPM 插件和 Modeler 2.0 插件。当我创建一个新的 JBPM 项目时,它要求 JBPM 运行时。我在互联网上搜索了
我是 JBPM 的新手。我下载并开始使用 eclipse。然后我安装了 JBPM 插件和 Modeler 2.0 插件。当我创建一个新的 JBPM 项目时,它要求 JBPM 运行时。我在互联网上搜索了
我目前正在将Windows 8.1应用程序移植到Windows 10 UAP应用程序,该应用程序使用互操作在C++和C#之间进行通信,并且 pop 以下错误: $(ProjectName).Inter
我正在使用 Parcel 来捆绑我的项目并 Jest 运行我的测试。 一切正常,但在测试中我有 async/await关键字,我必须导入 regenerator-runtime/runtime像这样:
一旦我尝试使用 Promises,Browserify 就会抛出此错误。 在 中找不到模块“regenerator-runtime/runtime” 我尝试过 Node 版本 10.15.3 和 12
我目前正在试验 quarkus,找不到在运行时更改一些 openapi 信息的方法(这里,我希望授权 url 根据环境而改变)。 应该可以通过使用 OASFilter 并从环境变量中提供信息来实现,但
我正在使用 rust_bert 汇总文本。我需要使用rust_bert::pipelines::summarization::SummarizationModel::new设置模型,该模型可以从互联网
我正在 Visual Studio 中处理其中一个新的“类库(NuGet 包)”项目。一切都很顺利,直到前几天它开始引发有关 System.Runtime.Extensions 程序集的错误: Ass
我正在使用 tokio::runtime::current_thread::Runtime我希望能够在同一个线程中运行 future 并停止 react 堆。页面上的示例未显示如何停止运行时。有什么办
我找不到如何声明 runtime.LockOSThread()和 runtime.UnlockOSThread() .我将其定义为 [runtime.LockOSThread()] 一些代码 [run
我有这样的代码, Routine 1 { runtime.LockOSThread() print something send int to routine 2 runtime.UnlockOSTh
我正在尝试执行此操作:当我单击“搜索”按钮时,命令提示符窗口打开。 我尝试使用ProcessBuilder,没有出现错误,但是不起作用。你能帮我一下吗? package sys.tool; impor
我的应用程序运行大约 4 小时后出现此错误。我不知道为什么会这样。该错误发生在 windows 7 和 windows XP 系统上。抱歉,我没有更多信息。我的应用程序运行大约 4 次后才收到此错误消
我收到错误:“此程序集是由比当前加载的运行时更新的运行时构建的,无法加载。” 我有一个 .NET 2.0 项目调用的 .NET 4.0 dll 项目。有没有办法调和框架的差异? 最佳答案 I have
我有一个 WIX 安装程序,它在安装过程中执行自定义操作。当我运行 WIX 安装程序并遇到它的第一个自定义操作时,安装程序失败,我在 MSI 日志中收到如下错误: Action start 12:
我正在尝试提交 spark 作业 它是这样开始的: import javax.xml.parsers.{SAXParser, SAXParserFactory} import org.apache.s
我正在做一些 WCF 工作,但我不明白为什么会遇到这个错误。 System.Runtime.Serialization.DataContractAttribute命名空间中不存在 System.Run
我尝试按照 this 在 React 应用程序中使用 async/await : 目前,我正在运行webpack --config webpack.dev.config.js --watch --pr
我已经从托管的 Window Server 2008 下载了已发布的(代码隐藏文件不存在,与 bin 文件夹中的 dll 结合)Web 应用程序,并在调试该应用程序时使用 Visual Studio
我是一名优秀的程序员,十分优秀!