Skip to content

Commit

Permalink
Adds a friendly error msg when config file is empty
Browse files Browse the repository at this point in the history
Also makes high res indices option for recogniser base optional through a default value
  • Loading branch information
atruskie committed Apr 9, 2021
1 parent 1f5c47e commit 66a0ad1
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/Acoustics.Shared/ConfigFile/ConfigFile.Deserialize.cs
Original file line number Diff line number Diff line change
@@ -120,6 +120,11 @@ private static T LoadAndCache<T>(string path, Func<T> factory)
(generic, loadedConfig) = Yaml.LoadAndDeserialize<T>(path);
}

if (loadedConfig is null)
{
throw new ConfigFileException($"Tried to load the {path} config file but it looks like it was empty. Add some content?", path);
}

// if implements Config in any subtype (more specific than IConfig)
if (loadedConfig is Config config)
{
2 changes: 1 addition & 1 deletion src/AnalysisPrograms/Recognizers/Base/RecognizerBase.cs
Original file line number Diff line number Diff line change
@@ -444,7 +444,7 @@ public RecognizerConfig()
};
}

public string HighResolutionIndicesConfig { get; set; }
public string HighResolutionIndicesConfig { get; set; } = "Towsey.Acoustic.HiResIndicesForRecognisers.yml";

public AcousticIndices.AcousticIndicesConfig HighResolutionIndices { get; private set; }
}

0 comments on commit 66a0ad1

Please sign in to comment.