Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error messages get stomped when loading files #17

Open
GoogleCodeExporter opened this issue Mar 16, 2015 · 1 comment
Open

Error messages get stomped when loading files #17

GoogleCodeExporter opened this issue Mar 16, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

When attempting to load a file with syntax or other errors, SLB checks the 
return status of luaL_loadfile and sets _lastError appropriately. However, it 
then goes on to unconditionally try to execute the loaded object, which in the 
case of an error may not be a function. 

The result is an unhelpful error message like

    SLB Exception: 
    -------------------------------------------------------
    Lua Error:
            attempt to call a string value
    Traceback:
             [ 0 (C) ] 

Applying a patch like

diff --git a/src/Script.cpp b/src/Script.cpp
--- a/src/Script.cpp
+++ b/src/Script.cpp
@@ -171,7 +171,7 @@ namespace SLB {
     }

     // otherwise...
-    if( _errorHandler->call(_lua_state, 0, 0))
+    if(result && _errorHandler->call(_lua_state, 0, 0))
     {
       _lastError = lua_tostring(L,-1);
       result = false;

seems to produce more appropriate error messages, such as

    cannot open test1.lua: No such file or directory

or

    test1.lua:41: syntax error near <eof>

Original issue reported on code.google.com by [email protected] on 21 Aug 2012 at 5:10

@GoogleCodeExporter
Copy link
Author

ACK, thanks!

Original comment by [email protected] on 28 Aug 2012 at 7:11

  • Changed state: Accepted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant