]> git.proxmox.com Git - pve-common.git/blobdiff - src/PVE/SectionConfig.pm
SectionConfig: parse_config: add errors to result
[pve-common.git] / src / PVE / SectionConfig.pm
index b46b59ed259fae053b0880e3f1a7deb3acab9ca0..af0af03d7beec66fea159b7191d26f9a04beeaf7 100644 (file)
@@ -311,6 +311,7 @@ sub parse_config {
        }
     };
 
+    my $errors = [];
     while (@lines) {
        my $line = $nextline->();
        next if !$line;
@@ -349,7 +350,15 @@ sub parse_config {
                        die "duplicate attribute\n" if defined($config->{$k});
                        $config->{$k} = $plugin->check_value($type, $k, $v, $sectionId);
                    };
-                   warn "$errprefix (section '$sectionId') - unable to parse value of '$k': $@" if $@;
+                   if (my $err = $@) {
+                       warn "$errprefix (section '$sectionId') - unable to parse value of '$k': $err";
+                       push @$errors, {
+                           context => $errprefix,
+                           section => $sectionId,
+                           key => $k,
+                           err => $err,
+                       };
+                   }
 
                } else {
                    warn "$errprefix (section '$sectionId') - ignore config line: $line\n";
@@ -368,8 +377,12 @@ sub parse_config {
        }
     }
 
-
-    my $cfg = { ids => $ids, order => $order, digest => $digest};
+    my $cfg = {
+       ids => $ids,
+       order => $order,
+       digest => $digest
+    };
+    $cfg->{errors} = $errors if scalar(@$errors) > 0;
 
     return $cfg;
 }