returning error in M when Lua code crashed. #12
-
Dear, At last my first discussion in this repository, In our M environment, we have some C plugins - you know - that accelerate some frequently used functions, Lua brings the opportunity to highly expand functionality in M. Just think about XML parsing, JSON, and many other stuff. Actually it is quite fun : you can literally write software, and switch from M to the Lua - whenever the other language is better suited - . For example : on our development system, we had more than 16.000.000 Lua calls from M in about 24 hours. However, I have a question I didn't find the answer for: In most cases, the reply variable just contains the error message. So, one has to be carefull, otherwise this message is used as the result of the function. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Hi Alain. The
Does this do what you need? |
Beta Was this translation helpful? Give feedback.
-
Yes, your examples work for me. They both set ret=0 because "x = 3" is valid code. The following also works for me, and demonstrates both a non-error and and error result:
FYI: my versions:
But it also works in previous YDB versions. |
Beta Was this translation helpful? Give feedback.
Hi Alain. The
mlua.lua()
return value tells you whether the result was an error. From the README:Does this do what you need?