Made the move_to error report a little more verbose. Resolves #964.
This commit is contained in:
parent
6e606ae530
commit
b69340695f
2 changed files with 19 additions and 22 deletions
|
|
@ -272,12 +272,10 @@ class ObjectDB(TypedObject):
|
||||||
|
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
errmsg = "Error: %s.location = %s creates a location loop." % (self.key, location)
|
errmsg = "Error: %s.location = %s creates a location loop." % (self.key, location)
|
||||||
logger.log_trace(errmsg)
|
raise RuntimeError(errmsg)
|
||||||
raise
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
errmsg = "Error (%s): %s is not a valid location." % (str(e), location)
|
errmsg = "Error (%s): %s is not a valid location." % (str(e), location)
|
||||||
logger.log_trace(errmsg)
|
raise RuntimeError(errmsg)
|
||||||
raise
|
|
||||||
|
|
||||||
def __location_del(self):
|
def __location_del(self):
|
||||||
"Cleanly delete the location reference"
|
"Cleanly delete the location reference"
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ from evennia.commands.cmdsethandler import CmdSetHandler
|
||||||
from evennia.commands import cmdhandler
|
from evennia.commands import cmdhandler
|
||||||
from evennia.utils import logger
|
from evennia.utils import logger
|
||||||
from evennia.utils.utils import (variable_from_module, lazy_property,
|
from evennia.utils.utils import (variable_from_module, lazy_property,
|
||||||
make_iter, to_str, to_unicode)
|
make_iter, to_unicode)
|
||||||
|
|
||||||
_MULTISESSION_MODE = settings.MULTISESSION_MODE
|
_MULTISESSION_MODE = settings.MULTISESSION_MODE
|
||||||
|
|
||||||
|
|
@ -592,10 +592,10 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
|
||||||
7. `self.at_after_move(source_location)`
|
7. `self.at_after_move(source_location)`
|
||||||
|
|
||||||
"""
|
"""
|
||||||
def logerr(string=""):
|
def logerr(string="", err=None):
|
||||||
"Simple log helper method"
|
"Simple log helper method"
|
||||||
logger.log_trace()
|
logger.log_trace()
|
||||||
self.msg(string)
|
self.msg("%s%s" % (string, "" if err is None else " (%s)" % err))
|
||||||
|
|
||||||
errtxt = _("Couldn't perform move ('%s'). Contact an admin.")
|
errtxt = _("Couldn't perform move ('%s'). Contact an admin.")
|
||||||
if not emit_to_obj:
|
if not emit_to_obj:
|
||||||
|
|
@ -618,8 +618,8 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
|
||||||
try:
|
try:
|
||||||
if not self.at_before_move(destination):
|
if not self.at_before_move(destination):
|
||||||
return
|
return
|
||||||
except Exception:
|
except Exception as err:
|
||||||
logerr(errtxt % "at_before_move()")
|
logerr(errtxt % "at_before_move()", err)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Save the old location
|
# Save the old location
|
||||||
|
|
@ -637,32 +637,31 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
|
||||||
if move_hooks:
|
if move_hooks:
|
||||||
try:
|
try:
|
||||||
source_location.at_object_leave(self, destination)
|
source_location.at_object_leave(self, destination)
|
||||||
except Exception:
|
except Exception as err:
|
||||||
logerr(errtxt % "at_object_leave()")
|
logerr(errtxt % "at_object_leave()", err)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if not quiet:
|
if not quiet:
|
||||||
#tell the old room we are leaving
|
#tell the old room we are leaving
|
||||||
try:
|
try:
|
||||||
self.announce_move_from(destination)
|
self.announce_move_from(destination)
|
||||||
except Exception:
|
except Exception as err:
|
||||||
logerr(errtxt % "at_announce_move()")
|
logerr(errtxt % "at_announce_move()", err)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Perform move
|
# Perform move
|
||||||
try:
|
try:
|
||||||
self.location = destination
|
self.location = destination
|
||||||
except Exception:
|
except Exception as err:
|
||||||
emit_to_obj.msg(errtxt % "location change")
|
logerr(errtxt % "location change", err)
|
||||||
logger.log_trace()
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if not quiet:
|
if not quiet:
|
||||||
# Tell the new room we are there.
|
# Tell the new room we are there.
|
||||||
try:
|
try:
|
||||||
self.announce_move_to(source_location)
|
self.announce_move_to(source_location)
|
||||||
except Exception:
|
except Exception as err:
|
||||||
logerr(errtxt % "announce_move_to()")
|
logerr(errtxt % "announce_move_to()", err)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if move_hooks:
|
if move_hooks:
|
||||||
|
|
@ -670,8 +669,8 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
|
||||||
# (the object has already arrived at this point)
|
# (the object has already arrived at this point)
|
||||||
try:
|
try:
|
||||||
destination.at_object_receive(self, source_location)
|
destination.at_object_receive(self, source_location)
|
||||||
except Exception:
|
except Exception as err:
|
||||||
logerr(errtxt % "at_object_receive()")
|
logerr(errtxt % "at_object_receive()", err)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Execute eventual extra commands on this object after moving it
|
# Execute eventual extra commands on this object after moving it
|
||||||
|
|
@ -679,8 +678,8 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
|
||||||
if move_hooks:
|
if move_hooks:
|
||||||
try:
|
try:
|
||||||
self.at_after_move(source_location)
|
self.at_after_move(source_location)
|
||||||
except Exception:
|
except Exception as err:
|
||||||
logerr(errtxt % "at_after_move")
|
logerr(errtxt % "at_after_move", err)
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue