]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Make ContainerFillSystem print contents on failure (#36128)
authorTayrtahn <tayrtahn@gmail.com>
Fri, 28 Mar 2025 15:37:34 +0000 (11:37 -0400)
committerGitHub <noreply@github.com>
Fri, 28 Mar 2025 15:37:34 +0000 (16:37 +0100)
* Make ContainerFill/EntityTableContainerFill print current contents when failing to spawn an entity

* List each entry on a new line; add fallback for empty

Content.Shared/Containers/ContainerFillSystem.cs

index 90eccb0341a39d01119a937be6c0568882810d7e..3d49079ea712a26b282639c4401f5975dcec3f92 100644 (file)
@@ -1,3 +1,4 @@
+using System.Linq;
 using System.Numerics;
 using Content.Shared.EntityTable;
 using Robust.Shared.Containers;
@@ -39,7 +40,8 @@ public sealed class ContainerFillSystem : EntitySystem
                 var ent = Spawn(proto, coords);
                 if (!_containerSystem.Insert(ent, container, containerXform: xform))
                 {
-                    Log.Error($"Entity {ToPrettyString(uid)} with a {nameof(ContainerFillComponent)} failed to insert an entity: {ToPrettyString(ent)}.");
+                    var alreadyContained = container.ContainedEntities.Count > 0 ? string.Join("\n", container.ContainedEntities.Select(e => $"\t - {EntityManager.ToPrettyString(e)}")) : "< empty >";
+                    Log.Error($"Entity {ToPrettyString(uid)} with a {nameof(ContainerFillComponent)} failed to insert an entity: {ToPrettyString(ent)}.\nCurrent contents:\n{alreadyContained}");
                     _transform.AttachToGridOrMap(ent);
                     break;
                 }
@@ -72,7 +74,8 @@ public sealed class ContainerFillSystem : EntitySystem
                 var spawn = Spawn(proto, coords);
                 if (!_containerSystem.Insert(spawn, container, containerXform: xform))
                 {
-                    Log.Error($"Entity {ToPrettyString(ent)} with a {nameof(EntityTableContainerFillComponent)} failed to insert an entity: {ToPrettyString(spawn)}.");
+                    var alreadyContained = container.ContainedEntities.Count > 0 ? string.Join("\n", container.ContainedEntities.Select(e => $"\t - {EntityManager.ToPrettyString(e)}")) : "< empty >";
+                    Log.Error($"Entity {ToPrettyString(ent)} with a {nameof(EntityTableContainerFillComponent)} failed to insert an entity: {ToPrettyString(spawn)}.\nCurrent contents:\n{alreadyContained}");
                     _transform.AttachToGridOrMap(spawn);
                     break;
                 }