From e13559d7b6a386f8d7e1afaff4fe5b64da7297a8 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Tue, 5 Feb 2008 09:20:06 -0800 Subject: better error messages on errors Try for complete sentences for describing problem. --- scripts/VyattaQosTrafficShaper.pm | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'scripts') diff --git a/scripts/VyattaQosTrafficShaper.pm b/scripts/VyattaQosTrafficShaper.pm index b9ece81..2b95a05 100644 --- a/scripts/VyattaQosTrafficShaper.pm +++ b/scripts/VyattaQosTrafficShaper.pm @@ -59,7 +59,7 @@ if ( $rate =~ /%$/ ) { my $percent = substr( $rate, 0, length($rate) - 1 ); if ( $percent < 0 || $percent > 100 ) { - die "Invalid percentage bandwidth\n"; + die "Invalid percentage bandwidth: $percent\n"; } $rate = ( $percent * $speed ) / 100.; @@ -77,15 +77,15 @@ my $id = $self->{_id}; my $matches = $self->{_match}; - die "Rate is not defined\n" if (! defined $rate ); - die "Class $id rate $rate > shaper rate $speed\n" if ($rate > $speed); + $rate <= $speed or + die "Rate for class $id ($rate) must be less than overall rate ($speed)\n"; # create the class my $cmd ="class add dev $dev parent 1:1 classid 1:$id htb rate $rate"; if ( defined $ceil) { - if ($ceil < $rate ) { - die "Rate limit (ceiling) $ceil < base rate $rate\n"; - } + + $ceil >= $rate or + die "Rate ceiling ($ceil) must be greater than base rate ($rate)\n"; $cmd .= " ceil $ceil"; } @@ -136,7 +136,7 @@ sub _getAutoRate { if ( $rate eq "auto" ) { $rate = VyattaQosUtil::interfaceRate($dev); if ( ! defined $rate ) { - die "Auto speed setting but can't get rate from $dev\n"; + die "Interface speed defined as auto but can't get rate from $dev\n"; } } else { $rate = VyattaQosUtil::getRate($rate); @@ -154,6 +154,8 @@ sub _define { $self->{_rate} = $config->returnValue("rate"); + $config->exists("default") + or die "Configuration not complete: missing default class\n"; $config->setLevel("$level default"); push @classes, new ShaperClass( $config, $defaultId); $config->setLevel($level); -- cgit v1.2.3