Skip to content

Commit

Permalink
Check errors from luaL_loadfile
Browse files Browse the repository at this point in the history
Otherwise we get "attempt to call a string value" from the next pcall instead of the actual error
  • Loading branch information
Daft-Freak committed Nov 9, 2023
1 parent 909e06f commit 9eb2bc7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ void init() {
if(!launchPath) {
launchPath = "main.lua";
}
luaL_loadfile(L, launchPath);
auto err = luaL_loadfile(L, launchPath);

if(err) {
blit::debugf("Error loading %s: %s\n", launchPath, lua_tostring(L, -1));
has_render = has_update = false;
return;
}

// Super important priming call that makes stuff not explode
if(lua_pcall(L, 0, 0, 0) != 0){
Expand Down

0 comments on commit 9eb2bc7

Please sign in to comment.