Lua has the luaL_error, and lua_error functions to be used inside a C function, like:
luaL_error( L, "something bad" );
This will cause that a error message was show and Lua execution halted. The error message will contain the line and file where it occurs:
Error: ../example/ex01.lua:6: something bad
Is there a similar function that shows the error but don't break the lua execution? but showing the line where it occurs.