Better error reporting
This commit is contained in:
parent
30a7473d10
commit
026f7bf0e4
@ -85,7 +85,13 @@ enhance_error = function(error_message)
|
|||||||
if not (error_message and error_message:match("%d|")) then
|
if not (error_message and error_message:match("%d|")) then
|
||||||
error_message = error_message or ""
|
error_message = error_message or ""
|
||||||
do
|
do
|
||||||
local fn_name = (error_message:match("attempt to call a nil value %(global '(.*)'%)") or error_message:match("attempt to call global '(.*)' %(a nil value%)"))
|
local fn_name = error_message:match("attempt to call a nil value %(method '(.*)'%)")
|
||||||
|
if fn_name then
|
||||||
|
local action_name = fn_name:from_lua_id()
|
||||||
|
error_message = "This object does not have the method '" .. tostring(action_name) .. "'."
|
||||||
|
else
|
||||||
|
do
|
||||||
|
fn_name = (error_message:match("attempt to call a nil value %(global '(.*)'%)") or error_message:match("attempt to call global '(.*)' %(a nil value%)"))
|
||||||
if fn_name then
|
if fn_name then
|
||||||
local action_name = fn_name:from_lua_id()
|
local action_name = fn_name:from_lua_id()
|
||||||
error_message = "The action '" .. tostring(action_name) .. "' is not defined."
|
error_message = "The action '" .. tostring(action_name) .. "' is not defined."
|
||||||
@ -162,6 +168,8 @@ enhance_error = function(error_message)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
local level = 2
|
local level = 2
|
||||||
while true do
|
while true do
|
||||||
local calling_fn = debug_getinfo(level)
|
local calling_fn = debug_getinfo(level)
|
||||||
|
@ -61,7 +61,10 @@ enhance_error = (error_message)->
|
|||||||
unless error_message and error_message\match("%d|")
|
unless error_message and error_message\match("%d|")
|
||||||
error_message or= ""
|
error_message or= ""
|
||||||
-- When calling 'nil' actions, make a better error message
|
-- When calling 'nil' actions, make a better error message
|
||||||
if fn_name = (error_message\match("attempt to call a nil value %(global '(.*)'%)") or
|
if fn_name = error_message\match("attempt to call a nil value %(method '(.*)'%)")
|
||||||
|
action_name = fn_name\from_lua_id!
|
||||||
|
error_message = "This object does not have the method '#{action_name}'."
|
||||||
|
elseif fn_name = (error_message\match("attempt to call a nil value %(global '(.*)'%)") or
|
||||||
error_message\match("attempt to call global '(.*)' %(a nil value%)"))
|
error_message\match("attempt to call global '(.*)' %(a nil value%)"))
|
||||||
|
|
||||||
action_name = fn_name\from_lua_id!
|
action_name = fn_name\from_lua_id!
|
||||||
|
Loading…
Reference in New Issue
Block a user