diff --git a/CHANGELIST.md b/CHANGELIST.md index bac869f1..35635669 100644 --- a/CHANGELIST.md +++ b/CHANGELIST.md @@ -50,6 +50,7 @@ - Add unused passable func to OutputFile - Pass in new func for OutputFile - Use new func in Redumper +- Add runtime error for improperly created artifacts ### 3.2.1 (2024-08-05) diff --git a/MPF.Processors/OutputFile.cs b/MPF.Processors/OutputFile.cs index 2d974060..0681dc8e 100644 --- a/MPF.Processors/OutputFile.cs +++ b/MPF.Processors/OutputFile.cs @@ -142,8 +142,6 @@ namespace MPF.Processors /// private readonly Func? _existsFunc; - // TODO: Add validation that a key exists if the artifact flag is present - /// /// Create an OutputFile with a single filename /// @@ -169,6 +167,10 @@ namespace MPF.Processors ArtifactKey = null; _flags = flags; _existsFunc = existsFunc; + + // Ensure artifacts have a key + if (IsArtifact && string.IsNullOrEmpty(ArtifactKey)) + throw new InvalidDataException($"{flags} should not contain the Artifact or Binary flag"); } /// @@ -180,6 +182,10 @@ namespace MPF.Processors ArtifactKey = artifactKey; _flags = flags; _existsFunc = existsFunc; + + // Ensure artifacts have a key + if (IsArtifact && string.IsNullOrEmpty(ArtifactKey)) + throw new InvalidDataException($"{flags} should not contain the Artifact or Binary flag"); } ///