X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=src%2FPVE%2FSectionConfig.pm;h=af0af03d7beec66fea159b7191d26f9a04beeaf7;hb=d37a71867233a09803e825f0249a1c7df8be25a0;hp=cf87d6f6c3faa5c41f200f5f890cfb29f8304c9b;hpb=848231afd273a7641cf2551ebb004dcba39822b5;p=pve-common.git diff --git a/src/PVE/SectionConfig.pm b/src/PVE/SectionConfig.pm index cf87d6f..af0af03 100644 --- a/src/PVE/SectionConfig.pm +++ b/src/PVE/SectionConfig.pm @@ -3,6 +3,7 @@ package PVE::SectionConfig; use strict; use warnings; +use Carp; use Digest::SHA; use PVE::Exception qw(raise_param_exc); @@ -198,6 +199,8 @@ sub init { sub lookup { my ($class, $type) = @_; + croak "cannot lookup undefined type!" if !defined($type); + my $pdata = $class->private(); my $plugin = $pdata->{plugins}->{$type}; @@ -308,6 +311,7 @@ sub parse_config { } }; + my $errors = []; while (@lines) { my $line = $nextline->(); next if !$line; @@ -346,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"; @@ -365,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; }