Slightly improve error message when importing wrongly named atch files.

This commit is contained in:
Ottermandias 2025-05-28 13:54:23 +02:00
parent ebe45c6a47
commit 2c115eda94

View file

@ -34,6 +34,7 @@ public sealed class AtchMetaDrawer : MetaDrawer<AtchIdentifier, AtchEntry>, ISer
private AtchFile? _currentBaseAtchFile;
private AtchPoint? _currentBaseAtchPoint;
private readonly AtchPointCombo _combo;
private string _fileImport = string.Empty;
public AtchMetaDrawer(ModMetaEditor editor, MetaFileManager metaFiles)
: base(editor, metaFiles)
@ -48,6 +49,8 @@ public sealed class AtchMetaDrawer : MetaDrawer<AtchIdentifier, AtchEntry>, ISer
=> obj.ToName();
}
private sealed class RaceCodeException(string filePath) : Exception($"Could not identify race code from path {filePath}.");
public void ImportFile(string filePath)
{
try
@ -57,7 +60,8 @@ public sealed class AtchMetaDrawer : MetaDrawer<AtchIdentifier, AtchEntry>, ISer
var gr = Parser.ParseRaceCode(filePath);
if (gr is GenderRace.Unknown)
throw new Exception($"Could not identify race code from path {filePath}.");
throw new RaceCodeException(filePath);
var text = File.ReadAllBytes(filePath);
var file = new AtchFile(text);
foreach (var point in file.Points)
@ -76,6 +80,12 @@ public sealed class AtchMetaDrawer : MetaDrawer<AtchIdentifier, AtchEntry>, ISer
}
}
}
catch (RaceCodeException ex)
{
Penumbra.Messager.AddMessage(new Notification(ex, "The imported .atch file does not contain a race code (cXXXX) in its name.",
"Could not import .atch file:",
NotificationType.Warning));
}
catch (Exception ex)
{
Penumbra.Messager.AddMessage(new Notification(ex, "Unable to import .atch file.", "Could not import .atch file:",