Permalink
Browse files

Python exceptions are now logged via LOG(error)

  • Loading branch information...
1 parent 3cff6eb commit 4b37a71683152d965cd60f7a3f5e442186ac9d1a @rcythr rcythr committed Mar 6, 2013
@@ -27,6 +27,8 @@ def validate(self):
def run(self):
actor = self.getActor()
+ abc = defg
+
actor.setFlag("BurstRunning")
actor.setFlag("BurstRunCooldown")
@@ -40,7 +40,7 @@ PythonScript::PythonScript(const string& filename)
catch (error_already_set &)
{
ScopedGilLock lock;
- PyErr_Print();
+ swganh::scripting::logPythonException();
}
}
@@ -90,7 +90,7 @@ void PythonScript::GetPythonException()
os << typestr << std::flush;
} catch (error_already_set const &) {
os << "Internal error getting error type:\n";
- PyErr_Print();
+ swganh::scripting::logPythonException();
}
os << ": ";
@@ -101,7 +101,7 @@ void PythonScript::GetPythonException()
os << valuestr << std::flush;
} catch (error_already_set const &) {
os << "Internal error getting value type:\n";
- PyErr_Print();
+ swganh::scripting::logPythonException();
}
if (tb) {
@@ -113,7 +113,7 @@ void PythonScript::GetPythonException()
os << "\nTraceback (recent call last):\n" << str;
} catch (error_already_set const &) {
os << "Internal error getting traceback:\n";
- PyErr_Print();
+ swganh::scripting::logPythonException();
}
} else {
os << std::endl;
@@ -19,8 +19,8 @@ PythonScriptCreator::PythonScriptCreator(std::string module_name, std::string cl
{
module_ = bp::import(module_name_.c_str());
}
- catch(bp::error_already_set& /*e*/)
- {
- PyErr_Print();
- }
+ catch (bp::error_already_set&)
+ {
+ swganh::scripting::logPythonException();
+ }
}
@@ -36,10 +36,10 @@ namespace scripting {
interfaceObj.reset(obj_pointer, [new_instance] (T*) {});
}
}
- catch(boost::python::error_already_set& /*e*/)
- {
- PyErr_Print();
- }
+ catch (bp::error_already_set&)
+ {
+ swganh::scripting::logPythonException();
+ }
return interfaceObj;
}
@@ -76,4 +76,6 @@ namespace scripting {
}
}
+ void logPythonException();
+
}} // namespace swganh::scripting
@@ -47,7 +47,7 @@ namespace attributes {
}
catch (bp::error_already_set&)
{
- PyErr_Print();
+ swganh::scripting::logPythonException();
}
return AttributeListMessage();
}
@@ -22,10 +22,10 @@ PythonAttributesCreator::PythonAttributesCreator(std::string module_name, std::s
{
module_ = bp::import(module_name_.c_str());
}
- catch(bp::error_already_set& /*e*/)
- {
- PyErr_Print();
- }
+ catch (bp::error_already_set&)
+ {
+ swganh::scripting::logPythonException();
+ }
}
std::shared_ptr<AttributeTemplateInterface> PythonAttributesCreator::operator() (swganh::app::SwganhKernel* kernel)
@@ -49,10 +49,10 @@ std::shared_ptr<AttributeTemplateInterface> PythonAttributesCreator::operator()
attribute_template.reset(obj_pointer, [new_instance] (AttributeTemplateInterface*) {});
}
}
- catch(bp::error_already_set& /*e*/)
- {
- PyErr_Print();
- }
+ catch (bp::error_already_set&)
+ {
+ swganh::scripting::logPythonException();
+ }
return attribute_template;
}
@@ -44,9 +44,9 @@ uint64_t PyCharacterCreate::CreateCharacter(
return created_creature->GetObjectId();
}
}
- catch(bp::error_already_set& /*e*/)
- {
- PyErr_Print();
- }
+ catch (bp::error_already_set&)
+ {
+ swganh::scripting::logPythonException();
+ }
return 0;
}
@@ -39,10 +39,10 @@ class BuffWrap : public BuffInterface, wrapper<BuffInterface>
run(creature);
}
}
- catch(boost::python::error_already_set& /*e*/)
- {
- PyErr_Print();
- }
+ catch (error_already_set&)
+ {
+ swganh::scripting::logPythonException();
+ }
}
virtual void RemoveBuff(std::shared_ptr<swganh::object::Creature> creature)
@@ -55,10 +55,10 @@ class BuffWrap : public BuffInterface, wrapper<BuffInterface>
run(creature);
}
}
- catch(boost::python::error_already_set& /*e*/)
- {
- PyErr_Print();
- }
+ catch (error_already_set&)
+ {
+ swganh::scripting::logPythonException();
+ }
}
virtual std::string GetName()
@@ -71,10 +71,10 @@ class BuffWrap : public BuffInterface, wrapper<BuffInterface>
return run().as<std::string>();
}
}
- catch(boost::python::error_already_set& /*e*/)
- {
- PyErr_Print();
- }
+ catch (boost::python::error_already_set&)
+ {
+ swganh::scripting::logPythonException();
+ }
return "";
}
@@ -89,10 +89,10 @@ class BuffWrap : public BuffInterface, wrapper<BuffInterface>
return run();
}
}
- catch(boost::python::error_already_set& /*e*/)
- {
- PyErr_Print();
- }
+ catch (boost::python::error_already_set&)
+ {
+ swganh::scripting::logPythonException();
+ }
return 0;
}
@@ -22,10 +22,10 @@ PythonBuffCreator::PythonBuffCreator(std::string module_name, std::string class_
{
module_ = bp::import(module_name_.c_str());
}
- catch(bp::error_already_set& /*e*/)
- {
- PyErr_Print();
- }
+ catch (bp::error_already_set&)
+ {
+ swganh::scripting::logPythonException();
+ }
}
std::shared_ptr<BuffInterface> PythonBuffCreator::operator() ()
@@ -48,10 +48,10 @@ std::shared_ptr<BuffInterface> PythonBuffCreator::operator() ()
buff.reset(obj_pointer, [new_instance] (BuffInterface*) {});
}
}
- catch(bp::error_already_set& /*e*/)
- {
- PyErr_Print();
- }
+ catch (bp::error_already_set&)
+ {
+ swganh::scripting::logPythonException();
+ }
return buff;
}
@@ -56,10 +56,10 @@ struct BaseCombatCommandWrapper : BaseCombatCommand, bp::wrapper<BaseCombatComma
this->BaseCombatCommand::Run();
}
- catch(bp::error_already_set& /*e*/)
- {
- PyErr_Print();
- }
+ catch (bp::error_already_set&)
+ {
+ swganh::scripting::logPythonException();
+ }
return callback;
}
@@ -79,10 +79,10 @@ struct BaseCombatCommandWrapper : BaseCombatCommand, bp::wrapper<BaseCombatComma
this->BaseCombatCommand::SetCommandProperties(properties);
}
}
- catch(bp::error_already_set& /*e*/)
- {
- PyErr_Print();
- }
+ catch (bp::error_already_set&)
+ {
+ swganh::scripting::logPythonException();
+ }
}
private:
@@ -50,10 +50,10 @@ struct BaseSwgCommandWrapper : BaseSwgCommand, bp::wrapper<BaseSwgCommand>
validated = this->BaseSwgCommand::Validate();
}
}
- catch(bp::error_already_set& /*e*/)
- {
- PyErr_Print();
- }
+ catch (bp::error_already_set&)
+ {
+ swganh::scripting::logPythonException();
+ }
return validated;
}
@@ -74,10 +74,10 @@ struct BaseSwgCommandWrapper : BaseSwgCommand, bp::wrapper<BaseSwgCommand>
callback.reset(std::shared_ptr<CommandCallback>(obj_pointer, [result] (CommandCallback*) {}));
}
}
- catch(bp::error_already_set& /*e*/)
- {
- PyErr_Print();
- }
+ catch (bp::error_already_set&)
+ {
+ swganh::scripting::logPythonException();
+ }
return callback;
}
@@ -96,10 +96,10 @@ struct BaseSwgCommandWrapper : BaseSwgCommand, bp::wrapper<BaseSwgCommand>
this->BaseSwgCommand::SetCommandProperties(properties);
}
}
- catch(bp::error_already_set& /*e*/)
- {
- PyErr_Print();
- }
+ catch (bp::error_already_set&)
+ {
+ swganh::scripting::logPythonException();
+ }
}
void PostRun(bool success)
{
@@ -116,10 +116,10 @@ struct BaseSwgCommandWrapper : BaseSwgCommand, bp::wrapper<BaseSwgCommand>
this->BaseSwgCommand::PostRun(success);
}
}
- catch(bp::error_already_set& /*e*/)
- {
- PyErr_Print();
- }
+ catch (bp::error_already_set&)
+ {
+ swganh::scripting::logPythonException();
+ }
}
};
@@ -147,10 +147,10 @@ class CommandCallbackWrapper : public CommandCallback, bp::wrapper<CommandCallba
callback.reset(std::shared_ptr<CommandCallback>(obj_pointer, [result] (CommandCallback*) {}));
}
}
- catch(bp::error_already_set& /*e*/)
- {
- PyErr_Print();
- }
+ catch (bp::error_already_set&)
+ {
+ swganh::scripting::logPythonException();
+ }
}
return callback;
@@ -31,10 +31,10 @@ PythonCommandCreator::PythonCommandCreator(std::string module_name, std::string
{
command_module_ = bp::import(module_name_.c_str());
}
- catch(bp::error_already_set& /*e*/)
- {
- PyErr_Print();
- }
+ catch (bp::error_already_set&)
+ {
+ swganh::scripting::logPythonException();
+ }
}
std::shared_ptr<CommandInterface> PythonCommandCreator::operator() (
@@ -61,10 +61,10 @@ std::shared_ptr<CommandInterface> PythonCommandCreator::operator() (
command->SetCommandProperties(properties);
}
}
- catch(bp::error_already_set& /*e*/)
- {
- PyErr_Print();
- }
+ catch (bp::error_already_set&)
+ {
+ swganh::scripting::logPythonException();
+ }
return command;
}
@@ -504,8 +504,8 @@ void ObjectManager::LoadPythonObjectTemplates()
auto python_template = module.attr("templates");
object_templates_ = bp::extract<PythonTemplateMap>(python_template);
}
- catch(bp::error_already_set&)
+ catch (bp::error_already_set&)
{
- PyErr_Print();
+ swganh::scripting::logPythonException();
}
}
@@ -43,7 +43,7 @@ namespace object {
}
catch (bp::error_already_set&)
{
- PyErr_Print();
+ swganh::scripting::logPythonException();
}
return make_shared<Object>();
}
@@ -81,10 +81,10 @@ void SpawnService::Startup()
SHUTTLE_AWAY_TIME_SECONDS = boost::python::extract<uint32_t>(config.attr("SHUTTLE_AWAY_TIME_SECONDS"));
SHUTTLE_IN_PORT_TIME_SECONDS = boost::python::extract<uint32_t>(config.attr("SHUTTLE_IN_PORT_TIME_SECONDS"));
}
- catch(boost::python::error_already_set& /*e*/)
- {
- PyErr_Print();
- }
+ catch (boost::python::error_already_set&)
+ {
+ swganh::scripting::logPythonException();
+ }
//Build the default machines
//_buildCreatureMachine(kernel_, fsm_manager_);
Oops, something went wrong.

0 comments on commit 4b37a71

Please sign in to comment.