Last active
April 21, 2020 12:19
-
-
Save leandromoreira/6c1b587c64fc0d0fa9360b736d47c707 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Error during evaluation - syntactically invalid | |
code, err = loadstring(" a = 1 \n a a \n pring(a) \n") | |
print(code) | |
-- nil | |
print(err) | |
-- [string " a = 1 ..."]:2: '=' expected near 'a' | |
-- Error during runtime - syntactically valid | |
stringcode = " a = taketime.menu " | |
code, err = loadstring(stringcode) | |
print(err) -- no evaluation error | |
-- nil | |
print(code) -- a runtime error will happen once we execute this function | |
-- function: 0x40a068a0 | |
function err_handler(err_msg) | |
print("an err was raised", err_msg) | |
return err_msg | |
end | |
status, ret = xpcall(code, err_handler) | |
print(status) | |
-- false | |
print(ret) | |
-- [string " a = taketime.menu "]:1: attempt to index global 'taketime' (a nil value) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment