diff --git a/lib/task_helpers/imports/reports.rb b/lib/task_helpers/imports/reports.rb index 1f369865c1f..ace8216ffe4 100644 --- a/lib/task_helpers/imports/reports.rb +++ b/lib/task_helpers/imports/reports.rb @@ -12,8 +12,7 @@ def import(options = {}) :overwrite => options[:overwrite], :save => true } - begin - report_fd = File.open(filename, 'r') + File.open(filename, 'r') do |report_fd| MiqReport.import(report_fd, report_options) rescue ActiveModel::UnknownAttributeError, RuntimeError => err $log.error("Error importing #{filename} : #{err.message}") diff --git a/lib/task_helpers/imports/widgets.rb b/lib/task_helpers/imports/widgets.rb index fbdc231e6b5..ebabe22cccf 100644 --- a/lib/task_helpers/imports/widgets.rb +++ b/lib/task_helpers/imports/widgets.rb @@ -12,8 +12,7 @@ def import(options = {}) :overwrite => options[:overwrite], :save => true } - begin - widget_fd = File.open(filename, 'r') + File.open(filename, 'r') do |widget_fd| MiqWidget.import(widget_fd, widget_options) rescue ActiveModel::UnknownAttributeError, RuntimeError => err $log.error("Error importing #{filename} : #{err.message}")