[pve-devel] [PATCH common 2/4] cleanup: newlines in die/warn

Wolfgang Bumiller w.bumiller at proxmox.com
Mon Mar 21 08:40:46 CET 2016


On Mon, Mar 21, 2016 at 08:07:21AM +0100, Dietmar Maurer wrote:
> We use two different kinds of error reporting in print_property_string():
> 
> die "msg" 
> 
> and
> 
> raise "format error", errors => $errors;
> 
> ??

Most of the code seems to actuall be using die(). raise() seems to be
used for a few 'specific' occasions. Only get_options() uses raise() in
general (next to a die() on an internal error that should have been
caught by 'verifyapi' (I think)).

parse_property_string(), print_property_string() and validate() use
raise() after doing a check_object()/check_prop() which fills an $error
hash, so raise()-ing it makes sense in that it preserves its structure.

Other than that everything's using die().

> 
> 
> > On March 18, 2016 at 11:38 AM Wolfgang Bumiller <w.bumiller at proxmox.com>
> > wrote:
> > 
> > 
> > ---
> >  src/PVE/JSONSchema.pm | 8 ++++----
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> > 
> > diff --git a/src/PVE/JSONSchema.pm b/src/PVE/JSONSchema.pm
> > index ac64342..f9b7a5a 100644
> > --- a/src/PVE/JSONSchema.pm
> > +++ b/src/PVE/JSONSchema.pm
> > @@ -545,7 +545,7 @@ sub print_property_string {
> >  
> >      if (ref($format) ne 'HASH') {
> >  	my $schema = $format_list->{$format};
> > -	die "not a valid format: $format" if !$schema;
> > +	die "not a valid format: $format\n" if !$schema;
> >  	$format = $schema;
> >      }
> >  
> > @@ -568,7 +568,7 @@ sub print_property_string {
> >  	# Skip default keys
> >  	if ($format->{$key}->{default_key}) {
> >  	    if ($default_key) {
> > -		warn "multiple default keys in schema ($default_key, $key)";
> > +		warn "multiple default keys in schema ($default_key, $key)\n";
> >  	    } else {
> >  		$default_key = $key;
> >  		$skipped{$key} = 1;
> > @@ -588,7 +588,7 @@ sub print_property_string {
> >      foreach my $key (sort keys %$data) {
> >  	delete $required{$key};
> >  	next if $skipped{$key};
> > -	die "invalid key: $key" if !$allowed{$key};
> > +	die "invalid key: $key\n" if !$allowed{$key};
> >  
> >  	my $typeformat = $format->{$key}->{format};
> >  	my $value = $data->{$key};
> > @@ -604,7 +604,7 @@ sub print_property_string {
> >      }
> >  
> >      if (my $missing = join(',', keys %required)) {
> > -	die "missing properties: $missing";
> > +	die "missing properties: $missing\n";
> >      }
> >  
> >      return $text;
> > -- 
> > 2.1.4
> > 
> > 
> > _______________________________________________
> > pve-devel mailing list
> > pve-devel at pve.proxmox.com
> > http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
> > 




More information about the pve-devel mailing list