Faidon Liambotis has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/403699 )

Change subject: network: reword slice_network_constants' errors
......................................................................

network: reword slice_network_constants' errors

Too long/verbose and also raising ArgumentError instead of ParseError.

Change-Id: I18b17e58db42507ac859cee5d5b17a5a4e749d2b
---
M modules/network/lib/puppet/parser/functions/slice_network_constants.rb
1 file changed, 13 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/99/403699/1

diff --git 
a/modules/network/lib/puppet/parser/functions/slice_network_constants.rb 
b/modules/network/lib/puppet/parser/functions/slice_network_constants.rb
index 322dd07..541c3aa 100644
--- a/modules/network/lib/puppet/parser/functions/slice_network_constants.rb
+++ b/modules/network/lib/puppet/parser/functions/slice_network_constants.rb
@@ -37,8 +37,11 @@
 #
 module Puppet::Parser::Functions
   newfunction(:slice_network_constants, :type => :rvalue, :arity => -2) do 
|args|
-    fail ArgumentError, 'slice_network_constants() requires an argument' if 
args.empty?
-    fail ArgumentError, 'slice_network_constants() cannot handle more than 2 
values' if args.length > 2
+    if args.empty? || args.length > 2
+      raise(Puppet::ParseError, "slice_network_constants(): " +
+            "Wrong number of arguments given (#{args.length})")
+    end
+
     all_network_subnets = lookupvar('all_network_subnets')
     realm = args[0]
     options = args[1] if args.length > 1
@@ -48,16 +51,20 @@
     description = options['description'] if options
 
     unless all_network_subnets.key?(realm)
-        fail ArgumentError, 'slice_network_constants() realm non existant in 
network::subnets'
+        raise(Puppet::ParseError, "slice_network_constants(): " +
+              "realm non-existent in network::subnets")
     end
     if requested_site && (!all_network_subnets[realm].key? requested_site)
-        fail ArgumentError, "slice_network_constants() site specified must be 
present in network::subnets[#{realm}]. #{requested_site} was provided"
+        raise(Puppet::ParseError, "slice_network_constants(): " +
+              "site #{requested_site} not in network::subnets[#{realm}]")
     end
     if requested_sphere && (!['public', 'private'].include? requested_sphere)
-        fail ArgumentError, "slice_network_constants() sphere can only be 
public/private. #{requested_sphere} was provided"
+        raise(Puppet::ParseError, "slice_network_constants(): " +
+              "sphere #{requested_sphere} is not valid")
     end
     if af && (!['ipv4', 'ipv6'].include? af)
-        fail ArgumentError, "slice_network_constants() address family 
specified can only be ipv4 or ipv6. #{af} was provided"
+        raise(Puppet::ParseError, "slice_network_constants(): " +
+              "address family #{af} is not valid")
     end
 
     # And let's get our data back

-- 
To view, visit https://gerrit.wikimedia.org/r/403699
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I18b17e58db42507ac859cee5d5b17a5a4e749d2b
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Faidon Liambotis <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to