Codechange: catch script exceptions by reference

pull/104/head
glx 5 years ago committed by glx22
parent a82e7ec281
commit 09004f3697

@ -95,7 +95,7 @@ void ScriptInstance::Initialize(const char *main_script, const char *instance_na
return;
}
ScriptObject::SetAllowDoCommand(true);
} catch (Script_FatalError e) {
} catch (Script_FatalError &e) {
this->is_dead = true;
this->engine->ThrowError(e.GetErrorMessage());
this->engine->ResumeError();
@ -188,7 +188,7 @@ void ScriptInstance::GameLoop()
}
try {
this->callback(this);
} catch (Script_Suspend e) {
} catch (Script_Suspend &e) {
this->suspend = e.GetSuspendTime();
this->callback = e.GetSuspendCallback();
@ -218,10 +218,10 @@ void ScriptInstance::GameLoop()
ScriptObject::SetAllowDoCommand(true);
/* Start the script by calling Start() */
if (!this->engine->CallMethod(*this->instance, "Start", _settings_game.script.script_max_opcode_till_suspend) || !this->engine->IsSuspended()) this->Died();
} catch (Script_Suspend e) {
} catch (Script_Suspend &e) {
this->suspend = e.GetSuspendTime();
this->callback = e.GetSuspendCallback();
} catch (Script_FatalError e) {
} catch (Script_FatalError &e) {
this->is_dead = true;
this->engine->ThrowError(e.GetErrorMessage());
this->engine->ResumeError();
@ -239,10 +239,10 @@ void ScriptInstance::GameLoop()
/* Continue the VM */
try {
if (!this->engine->Resume(_settings_game.script.script_max_opcode_till_suspend)) this->Died();
} catch (Script_Suspend e) {
} catch (Script_Suspend &e) {
this->suspend = e.GetSuspendTime();
this->callback = e.GetSuspendCallback();
} catch (Script_FatalError e) {
} catch (Script_FatalError &e) {
this->is_dead = true;
this->engine->ThrowError(e.GetErrorMessage());
this->engine->ResumeError();
@ -496,7 +496,7 @@ void ScriptInstance::Save()
this->engine->CrashOccurred();
return;
}
} catch (Script_FatalError e) {
} catch (Script_FatalError &e) {
/* If we don't mark the script as dead here cleaning up the squirrel
* stack could throw Script_FatalError again. */
this->is_dead = true;

@ -55,7 +55,7 @@ bool ScriptScanner::AddFile(const char *filename, size_t basepath_length, const
this->ResetEngine();
try {
this->engine->LoadScript(filename);
} catch (Script_FatalError e) {
} catch (Script_FatalError &e) {
DEBUG(script, 0, "Fatal error '%s' when trying to load the script '%s'.", e.GetErrorMessage(), filename);
return false;
}

@ -766,7 +766,7 @@ namespace SQConvert {
try {
/* Delegate it to a template that can handle this specific function */
return HelperT<Tmethod>::SQCall((Tcls *)real_instance, *(Tmethod *)ptr, vm);
} catch (SQInteger e) {
} catch (SQInteger &e) {
return e;
}
}
@ -827,7 +827,7 @@ namespace SQConvert {
try {
/* Delegate it to a template that can handle this specific function */
return HelperT<Tmethod>::SQCall((Tcls *)nullptr, *(Tmethod *)ptr, vm);
} catch (SQInteger e) {
} catch (SQInteger &e) {
return e;
}
}
@ -881,7 +881,7 @@ namespace SQConvert {
sq_setreleasehook(vm, -Tnparam, DefSQDestructorCallback<Tcls>);
instance->AddRef();
return 0;
} catch (SQInteger e) {
} catch (SQInteger &e) {
return e;
}
}
@ -903,7 +903,7 @@ namespace SQConvert {
sq_setreleasehook(vm, -nparam, DefSQDestructorCallback<Tcls>);
instance->AddRef();
return 0;
} catch (SQInteger e) {
} catch (SQInteger &e) {
return e;
}
}

Loading…
Cancel
Save