Skip to content

Commit eafb0e2

Browse files
author
Gerard Hickey
committed
Added exception handling to squelch fatal errors
1 parent f3a1811 commit eafb0e2

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

hanlon_microkernel/facter/hnl_mk_sys.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@
1717
lines = definition.split(/\n/)
1818

1919
# Create a hash of attributes for each section (i.e. cpu)
20-
attribs = Hash[ lines.collect { |l| l =~ /^\s*([^:]+):\s+(.*)\s*$/; v=$2; [$1.gsub(/\s/, '_'), v] } ]
20+
attribs = Hash[ lines.collect do |l|
21+
begin
22+
l =~ /^\s*([^:]+):\s+(.*)\s*$/; v=$2; [$1.gsub(/\s/, '_'), v]
23+
rescue NoMethodError
24+
puts "Error: (system class) unable to parse %{l}"
25+
end
26+
end ]
2127
attribs.each_pair do |attrib, val|
2228
Facter.add("mk_hw_sys_#{attrib}") do
2329
setcode { val }

0 commit comments

Comments
 (0)