Puppet Function: catch
- Defined in:
-
lib/puppet/functions/catch.rb
- Function type:
- Ruby 4.x API
Overview
catch(Array[Any, 2, 2] $arg, Optional[String] *$exceptions, Callable &$block) ⇒ Any
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/puppet/functions/catch.rb', line 1
Puppet::Functions.create_function(:catch) do
dispatch :catch do
param 'Array[Any, 2, 2]', :arg
optional_repeated_param 'String', :exceptions
block_param
end
def catch(arg, *exceptions)
if arg[1]
unless exceptions.empty?
fail arg[1]['exception'] unless exceptions.include? arg[1]['class']
end
yield arg[1]
else
arg[0]
end
end
end
|