Improve error messages for lua scenarios
This commit is contained in:
parent
32c7208a18
commit
18af2b7113
File diff suppressed because it is too large
Load Diff
|
@ -26,6 +26,7 @@
|
|||
#include "xml_parser.h"
|
||||
#include "randomgen.h"
|
||||
#include "leak_dumper.h"
|
||||
#include "platform_util.h"
|
||||
|
||||
using std::string;
|
||||
using std::list;
|
||||
|
@ -35,6 +36,7 @@ using Shared::Lua::LuaHandle;
|
|||
using Shared::Xml::XmlNode;
|
||||
using Shared::Util::RandomGen;
|
||||
|
||||
|
||||
namespace Glest{ namespace Game{
|
||||
|
||||
class World;
|
||||
|
@ -429,6 +431,8 @@ private:
|
|||
ControlType getFactionPlayerType(int factionIndex);
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
static void error(LuaHandle* luaHandle, const megaglest_runtime_error *mgErr, const char* file, const char* function, int line);
|
||||
|
||||
//callbacks, commands
|
||||
static int networkShowMessageForFaction(LuaHandle* luaHandle);
|
||||
static int networkShowMessageForTeam(LuaHandle* luaHandle);
|
||||
|
|
|
@ -310,7 +310,7 @@ void FactionType::load(const string &factionName, const TechTree *techTree, Chec
|
|||
} else if(current=="off") {
|
||||
healthbarVisible=healthbarVisible|hbvOff;
|
||||
} else {
|
||||
throw megaglest_runtime_error("Unknown Healthbar Visible Option: " + current, validationMode);
|
||||
throw megaglest_runtime_error("Unknown Healthbar Visible Option: " + current, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -912,7 +912,7 @@ const UnitType *FactionType::getUnitType(const string &name) const{
|
|||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] scanning [%s] idx = %d [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,name.c_str(),i,unitTypes[i].getName(false).c_str());
|
||||
}
|
||||
|
||||
throw megaglest_runtime_error("Unit type not found: [" + name + "] in faction type [" + this->name + "]");
|
||||
throw megaglest_runtime_error("Unit type not found: [" + name + "] in faction type [" + this->name + "]",true);
|
||||
}
|
||||
|
||||
const UnitType *FactionType::getUnitTypeById(int id) const{
|
||||
|
@ -932,7 +932,7 @@ const UnitType *FactionType::getUnitTypeById(int id) const{
|
|||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] scanning [%s] idx = %d [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,name.c_str(),i,unitTypes[i].getName(false).c_str());
|
||||
}
|
||||
|
||||
throw megaglest_runtime_error("Unit type not found: [" + intToStr(id) + "] in faction type [" + this->name + "]");
|
||||
throw megaglest_runtime_error("Unit type not found: [" + intToStr(id) + "] in faction type [" + this->name + "]",true);
|
||||
}
|
||||
|
||||
const UpgradeType *FactionType::getUpgradeType(const string &name) const{
|
||||
|
@ -952,7 +952,7 @@ const UpgradeType *FactionType::getUpgradeType(const string &name) const{
|
|||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] scanning [%s] idx = %d [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,name.c_str(),i,upgradeTypes[i].getName().c_str());
|
||||
}
|
||||
|
||||
throw megaglest_runtime_error("Upgrade type not found: [" + name + "] in faction type [" + this->name + "]");
|
||||
throw megaglest_runtime_error("Upgrade type not found: [" + name + "] in faction type [" + this->name + "]",true);
|
||||
}
|
||||
|
||||
int FactionType::getStartingResourceAmount(const ResourceType *resourceType) const{
|
||||
|
|
|
@ -547,7 +547,7 @@ void LuaScript::loadCode(string code, string name){
|
|||
printf("Function name [%s]\ncode:\n%s\n",name.c_str(),code.c_str());
|
||||
printf("=========================================================\n");
|
||||
|
||||
throw megaglest_runtime_error("Error loading lua code: " + errorToString(errorCode));
|
||||
throw megaglest_runtime_error("Error loading lua code: " + errorToString(errorCode),true);
|
||||
}
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d] name [%s], errorCode = %d\n",__FILE__,__FUNCTION__,__LINE__,name.c_str(),errorCode);
|
||||
|
@ -559,7 +559,7 @@ void LuaScript::loadCode(string code, string name){
|
|||
printf("Error calling lua pcall: %s\n",errorToString(errorCode).c_str());
|
||||
printf("=========================================================\n");
|
||||
|
||||
throw megaglest_runtime_error("Error initializing lua: " + errorToString(errorCode));
|
||||
throw megaglest_runtime_error("Error initializing lua: " + errorToString(errorCode),true);
|
||||
}
|
||||
|
||||
//const char *errMsg = lua_tostring(luaState, -1);
|
||||
|
@ -622,7 +622,7 @@ void LuaScript::endCall() {
|
|||
printf("Trying to execute [%s]\n",safeWrapper.c_str());
|
||||
int errorCode= runCode(safeWrapper);
|
||||
if(errorCode !=0 ) {
|
||||
throw megaglest_runtime_error("Error calling lua function [" + currentLuaFunction + "] error: " + errorToString(errorCode));
|
||||
throw megaglest_runtime_error("Error calling lua function [" + currentLuaFunction + "] error: " + errorToString(errorCode),true);
|
||||
}
|
||||
|
||||
//printf("Trying to execute [%s]\n",currentLuaFunction.c_str());
|
||||
|
@ -638,7 +638,7 @@ void LuaScript::endCall() {
|
|||
else {
|
||||
int errorCode= lua_pcall(luaState, argumentCount, 0, 0);
|
||||
if(errorCode !=0 ) {
|
||||
throw megaglest_runtime_error("Error calling lua function [" + currentLuaFunction + "] error: " + errorToString(errorCode));
|
||||
throw megaglest_runtime_error("Error calling lua function [" + currentLuaFunction + "] error: " + errorToString(errorCode),true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1139,7 +1139,7 @@ void LuaArguments::throwLuaError(const string &message) const{
|
|||
Lua_STREFLOP_Wrapper streflopWrapper;
|
||||
|
||||
string stackString = getStackText();
|
||||
throw megaglest_runtime_error("Lua error: " + message + "\n\nLua Stack:\n" + stackString);
|
||||
throw megaglest_runtime_error("Lua error: " + message + "\n\nLua Stack:\n" + stackString,true);
|
||||
}
|
||||
|
||||
}}//end namespace
|
||||
|
|
Loading…
Reference in New Issue