Advertisement

Lua + LuaBind and errors in lua code

Started by June 25, 2004 12:06 PM
1 comment, last by Tylon 20 years, 5 months ago
I am using LuaBind + Lua very successfully in my engine. I have one small problem with the whole thing. When run-time errors occur in the lua code, the program crashes with "This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information." For example, if I have a binded class Vector with x, y and z members and if i mis-type a member like vec = Vector(3, 4, 5) vec.c = 4 <- run time error, since member doesnt exist This obviously happens, since lua is dynamically typed, however, is there not some way to trap such errors, rather than making the program crash? Note, this is just an example, the program would also crash in other cases too, like if I call a function with incorrect number of parameters, and so on. If its not possible, then would there at least be some way to dump a stack trace or some kind of indication as to where the error happened? Its annoying when i write a big bit of lua code, then theres one little mis-typed variable there, and it takes me ages to find, because the program just crashes.
Maybe pcall will help? Basically it executes Lua code and catches any error that occurs.
Advertisement
thanks

This topic is closed to new replies.

Advertisement