From 236a72a0a17d3532cfa040fbbc047259ec0cffe9 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 21 Feb 2021 23:49:26 -0500 Subject: Entering an invalid debug command fails gracefully --- src/script_system.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/script_system.cpp b/src/script_system.cpp index c7c3938..769a872 100644 --- a/src/script_system.cpp +++ b/src/script_system.cpp @@ -235,6 +235,11 @@ void ScriptSystem::runDebugScript(std::string script) { newScript.runner.reset(new sol::thread(sol::thread::create(engine_.lua_state()))); sol::load_result loaded_script = newScript.runner->state().load(script); + if (!loaded_script.valid()) { + std::cout << "Error running debug command: " << script << std::endl; + return; + } + newScript.callable.reset(new sol::coroutine(loaded_script)); if (!*newScript.callable) { -- cgit 1.4.1