]> granicus.if.org Git - apache/commitdiff
Log error if unable to load lua file.
authorDaniel Earl Poirier <poirier@apache.org>
Sat, 1 May 2010 12:02:53 +0000 (12:02 +0000)
committerDaniel Earl Poirier <poirier@apache.org>
Sat, 1 May 2010 12:02:53 +0000 (12:02 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@939986 13f79535-47bb-0310-9956-ffa450edef68

modules/lua/lua_vmprep.c

index 8e4c3196505b925df135ce8905630d112c8da219..2adad2efa6dd9bd633165b387d383ebd3c40fa88 100644 (file)
@@ -325,7 +325,31 @@ AP_LUA_DECLARE(lua_State*)ap_lua_get_lua_state(apr_pool_t *lifecycle_pool,
             lua_pcall(L, 0, LUA_MULTRET, 0);
         }
         else {
-            luaL_loadfile(L, spec->file);
+            int rc;
+            ap_log_perror(APLOG_MARK, APLOG_DEBUG, 0, lifecycle_pool,
+                          "loading lua file %s", spec->file);
+            rc = luaL_loadfile(L, spec->file);
+            if (rc != 0) {
+                char *err;
+                switch (rc) {
+                case LUA_ERRSYNTAX: 
+                    err = "syntax error"; 
+                    break;
+                case LUA_ERRMEM:    
+                    err = "memory allocation error"; 
+                    break;
+                case LUA_ERRFILE:   
+                    err = "error opening or reading file"; 
+                    break;
+                default:
+                    err = "unknown error"; 
+                    break;
+                }
+                ap_log_perror(APLOG_MARK, APLOG_ERR, 0, lifecycle_pool,
+                              "Loading lua file %s: %s",
+                              spec->file, err);
+                return NULL;
+            }
             lua_pcall(L, 0, LUA_MULTRET, 0);
         }