[Asterisk-code-review] pbx lua: Support displaying lua error message if no debug t... (asterisk[master])
Christof Lauber
asteriskteam at digium.com
Wed Apr 25 01:24:41 CDT 2018
Christof Lauber has uploaded this change for review. ( https://gerrit.asterisk.org/8861
Change subject: pbx_lua: Support displaying lua error message if no debug table exists
......................................................................
pbx_lua: Support displaying lua error message if no debug table exists
The lua_error_function assumed that lua's debug table and traceback function
are always accessible, which is not the case. This fixes the error message
'Error in the lua error handler' triggred by switch exec() function.
If this happens lua's error message is shown without traceback.
Change-Id: I098c4e8bfe1598a0d4cf6f93a083b01a9b7639ac
---
M pbx/pbx_lua.c
1 file changed, 13 insertions(+), 0 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/61/8861/1
diff --git a/pbx/pbx_lua.c b/pbx/pbx_lua.c
index 741e950..46c2c0a 100644
--- a/pbx/pbx_lua.c
+++ b/pbx/pbx_lua.c
@@ -805,7 +805,20 @@
lua_pushliteral(L, "\n");
lua_getglobal(L, "debug");
+ if (!lua_istable(L, -1)) {
+ /* Have no 'debug' table for whatever reason */
+ lua_pop(L, 2);
+ /* Keep at least original err message */
+ lua_pushvalue(L, message_index);
+ return 1;
+ }
lua_getfield(L, -1, "traceback");
+ if (!lua_isfunction(L, -1)) {
+ /* Same here for traceback function */
+ lua_pop(L, 3);
+ lua_pushvalue(L, message_index);
+ return 1;
+ }
lua_remove(L, -2); /* remove the 'debug' table */
lua_pushvalue(L, message_index);
--
To view, visit https://gerrit.asterisk.org/8861
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I098c4e8bfe1598a0d4cf6f93a083b01a9b7639ac
Gerrit-Change-Number: 8861
Gerrit-PatchSet: 1
Gerrit-Owner: Christof Lauber <christof.lauber at annax.ch>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180425/4c51c37d/attachment-0001.html>
More information about the asterisk-code-review
mailing list