Added error handling in wren. Game while abort lauching and print error in logger

This commit is contained in:
Antoine Pilote
2021-07-03 18:31:32 -04:00
parent f5bcb12f61
commit b384154eb4
14 changed files with 50 additions and 22 deletions

View File

@@ -9,8 +9,15 @@ WrenScript::WrenScript(const std::string& path, const std::string& mod, bool isE
// Import statement
std::string source = "import \"" + path + "\" for " + mod;
CompiledSuccesfully = true;
// Import file as module
wrenInterpret(vm, "main", source.c_str());
WrenInterpretResult result = wrenInterpret(vm, "main", source.c_str());
if (result != WREN_RESULT_SUCCESS)
CompiledSuccesfully = false;
if (!CompiledSuccesfully)
return;
// Get handle to class
wrenEnsureSlots(vm, 1);
@@ -61,6 +68,9 @@ void WrenScript::CallFixedUpdate(float timestep)
void WrenScript::CallExit()
{
if (!CompiledSuccesfully)
return;
WrenVM* vm = ScriptingEngine::GetWrenVM();
wrenEnsureSlots(vm, 1);
wrenSetSlotHandle(vm, 0, this->m_Instance);