diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2008-02-05 09:20:06 -0800 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2008-02-05 09:20:06 -0800 |
commit | e13559d7b6a386f8d7e1afaff4fe5b64da7297a8 (patch) | |
tree | 06cf4ea7b81f9f1ae00cb18d093be592f1d98fa5 /scripts/VyattaQosTrafficShaper.pm | |
parent | 77f0136069ca2c4040fe7782ee87089dc11f086b (diff) | |
download | vyatta-cfg-qos-e13559d7b6a386f8d7e1afaff4fe5b64da7297a8.tar.gz vyatta-cfg-qos-e13559d7b6a386f8d7e1afaff4fe5b64da7297a8.zip |
better error messages on errors
Try for complete sentences for describing problem.
Diffstat (limited to 'scripts/VyattaQosTrafficShaper.pm')
-rw-r--r-- | scripts/VyattaQosTrafficShaper.pm | 16 |
1 files changed, 9 insertions, 7 deletions
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); |