Improve RSI error messages (#1894)

This commit is contained in:
mirrorcult
2021-07-25 03:06:36 -07:00
committed by GitHub
parent b19ae9e69e
commit f90462cf82

View File

@@ -102,7 +102,9 @@ namespace Robust.Client.ResourceManagement
if (reg.Src.Width % frameSize.X != 0 || reg.Src.Height % frameSize.Y != 0)
{
throw new RSILoadException("State image size is not a multiple of the icon size.");
var regDims = $"{reg.Src.Width}x{reg.Src.Height}";
var iconDims = $"{frameSize.X}x{frameSize.Y}";
throw new RSILoadException($"State '{stateObject.StateId}' image size ({regDims}) is not a multiple of the icon size ({iconDims}).");
}
// Load all frames into a list so we can operate on it more sanely.
@@ -250,7 +252,7 @@ namespace Robust.Client.ResourceManagement
}
if (manifestJson == null)
throw new RSILoadException("Manifest JSON was null!");
throw new RSILoadException($"Manifest JSON failed to deserialize!");
var size = manifestJson.Size;
var states = new StateMetadata[manifestJson.States.Length];
@@ -270,7 +272,7 @@ namespace Robust.Client.ResourceManagement
1 => RSI.State.DirectionType.Dir1,
4 => RSI.State.DirectionType.Dir4,
8 => RSI.State.DirectionType.Dir8,
_ => throw new RSILoadException($"Invalid direction: {dirValue} expected 1, 4 or 8")
_ => throw new RSILoadException($"Invalid direction for state '{stateName}': {dirValue}. Expected 1, 4 or 8")
};
}
else
@@ -291,7 +293,7 @@ namespace Robust.Client.ResourceManagement
if (delays.Length != dirValue)
{
throw new RSILoadException(
"DirectionsdirectionFramesList count does not match amount of delays specified.");
$"Direction frames list count ({dirValue}) does not match amount of delays specified ({delays.Length}) for state '{stateName}'.");
}
for (var i = 0; i < delays.Length; i++)