Browse Source

[optionsYaml] detect empty config file

Exilon 4 years ago
parent
commit
0323723496
1 changed files with 2 additions and 0 deletions
  1. 2 0
      Quick.Options.Serializer.Yaml.pas

+ 2 - 0
Quick.Options.Serializer.Yaml.pas

@@ -101,6 +101,8 @@ begin
   if FileExists(aFilename) then
   if FileExists(aFilename) then
   begin
   begin
     fileoptions := TFile.ReadAllText(aFilename,TEncoding.UTF8);
     fileoptions := TFile.ReadAllText(aFilename,TEncoding.UTF8);
+    if fileoptions.IsEmpty then EOptionLoadError.CreateFmt('Config file "%s" is empty!',[ExtractFileName(aFilename)]);
+
     aYamlObj := TYamlObject.ParseYAMLValue(fileoptions) as TYamlObject;
     aYamlObj := TYamlObject.ParseYAMLValue(fileoptions) as TYamlObject;
     if aYamlObj = nil then raise EOptionLoadError.CreateFmt('Config file "%s" is damaged or not well-formed Yaml format!',[ExtractFileName(aFilename)]);
     if aYamlObj = nil then raise EOptionLoadError.CreateFmt('Config file "%s" is damaged or not well-formed Yaml format!',[ExtractFileName(aFilename)]);
   end;
   end;