Add dimension to machine position debug statements

This commit is contained in:
D-Cysteine 2021-07-24 19:50:27 -06:00 committed by repo_alt
parent 6f8bfbf188
commit e940d5c745
2 changed files with 12 additions and 6 deletions

View File

@ -780,7 +780,7 @@ class Machine(val host: MachineHost) extends prefab.ManagedEnvironment with mach
catch {
case t: Throwable =>
OpenComputers.log.error(
s"""Unexpected error loading a state of computer at (${host.xPosition}, ${host.yPosition}, ${host.zPosition}). """ +
s"""Unexpected error loading a state of computer at ${machinePosition}. """ +
s"""State: ${state.headOption.fold("no state")(_.toString)}. Unless you're upgrading/downgrading across a major version, please report this! Thank you.""", t)
close()
}
@ -862,7 +862,7 @@ class Machine(val host: MachineHost) extends prefab.ManagedEnvironment with mach
catch {
case t: Throwable =>
OpenComputers.log.error(
s"""Unexpected error saving a state of computer at (${host.xPosition}, ${host.yPosition}, ${host.zPosition}). """ +
s"""Unexpected error saving a state of computer at ${machinePosition}. """ +
s"""State: ${state.headOption.fold("no state")(_.toString)}. Unless you're upgrading/downgrading across a major version, please report this! Thank you.""", t)
}
})
@ -1039,6 +1039,9 @@ class Machine(val host: MachineHost) extends prefab.ManagedEnvironment with mach
// Keep track of time spent executing the computer.
cpuTotal += System.nanoTime() - cpuStart
}
/** Helper method for printing the machine position in error messages and debug statements. */
private def machinePosition = s"(${host.xPosition}, ${host.yPosition}, ${host.zPosition}, ${host.world().provider.dimensionId})"
}
object Machine extends MachineAPI {

View File

@ -376,7 +376,7 @@ abstract class NativeLuaArchitecture(val machine: api.machine.Machine) extends A
try lua.gc(LuaState.GcAction.COLLECT, 0) catch {
case t: Throwable =>
OpenComputers.log.warn(s"Error cleaning up loaded computer @ (${machine.host.xPosition}, ${machine.host.yPosition}, ${machine.host.zPosition}). This either means the server is badly overloaded or a user created an evil __gc method, accidentally or not.")
OpenComputers.log.warn(s"Error cleaning up loaded computer @ ${machinePosition}. This either means the server is badly overloaded or a user created an evil __gc method, accidentally or not.")
machine.crash("error in garbage collector, most likely __gc method timed out")
}
} catch {
@ -414,19 +414,22 @@ abstract class NativeLuaArchitecture(val machine: api.machine.Machine) extends A
try lua.gc(LuaState.GcAction.COLLECT, 0) catch {
case t: Throwable =>
OpenComputers.log.warn(s"Error cleaning up loaded computer @ (${machine.host.xPosition}, ${machine.host.yPosition}, ${machine.host.zPosition}). This either means the server is badly overloaded or a user created an evil __gc method, accidentally or not.")
OpenComputers.log.warn(s"Error cleaning up loaded computer @ ${machinePosition}. This either means the server is badly overloaded or a user created an evil __gc method, accidentally or not.")
machine.crash("error in garbage collector, most likely __gc method timed out")
}
} catch {
case e: LuaRuntimeException =>
OpenComputers.log.warn(s"Could not persist computer @ (${machine.host.xPosition}, ${machine.host.yPosition}, ${machine.host.zPosition}).\n${e.toString}" + (if (e.getLuaStackTrace.isEmpty) "" else "\tat " + e.getLuaStackTrace.mkString("\n\tat ")))
OpenComputers.log.warn(s"Could not persist computer @ ${machinePosition}.\n${e.toString}" + (if (e.getLuaStackTrace.isEmpty) "" else "\tat " + e.getLuaStackTrace.mkString("\n\tat ")))
nbt.removeTag("state")
case e: LuaGcMetamethodException =>
OpenComputers.log.warn(s"Could not persist computer @ (${machine.host.xPosition}, ${machine.host.yPosition}, ${machine.host.zPosition}).\n${e.toString}")
OpenComputers.log.warn(s"Could not persist computer @ ${machinePosition}.\n${e.toString}")
nbt.removeTag("state")
}
// Limit memory again.
recomputeMemory(machine.host.internalComponents)
}
/** Helper method for printing the machine position in error messages and debug statements. */
private def machinePosition = s"(${machine.host.xPosition}, ${machine.host.yPosition}, ${machine.host.zPosition}, ${machine.host.world().provider.dimensionId})"
}