user441521
user441521

Reputation: 6998

How to handle lua_error() in Lua when it's fired from C

I have a C DLL that I load into Lua. The DLL will call lua_error() when there is an error. In Lua I get a message box with an error description. Is there any way for me to handle this better? Some kind of try/catch on Lua's side or something?

Upvotes: 2

Views: 745

Answers (1)

Nicol Bolas
Nicol Bolas

Reputation: 474316

It's handled no differently than if your Lua script had called error. If you want to call a function that may issue a Lua error (whether C/C++ or Lua), and you want to handle the error condition instead of just stopping, then you should use pcall to call the function.

Upvotes: 5

Related Questions