Skip to content
This repository has been archived by the owner on Jun 19, 2020. It is now read-only.

Commit

Permalink
(FACT-2555) Improve error handling for os_hierarchy.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bogdan Irimie committed Apr 28, 2020
1 parent 436cc69 commit 783b300
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/framework/detector/os_hierarchy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,23 @@ class OsHierarchy
def initialize
@log = Log.new(self)
json_file = Util::FileHelper.safe_read('os_hierarchy.json')
@json_data = JSON.parse(json_file)
rescue JSON::ParserError => _e
@log.error('Could not parse os_hierarchy json')

begin
@json_data = JSON.parse(json_file)
rescue JSON::ParserError => _e
@log.error('Could not parse os_hierarchy json')
end
end

def construct_hierarchy(searched_os)
return [] if searched_os.nil?

searched_os = searched_os.to_s.capitalize
if @json_data.nil?
@log.debug('There is no os_hierarchy, will fall back on current os name')
return [searched_os]
end

@searched_path = []
search(@json_data, searched_os, [])

Expand Down

0 comments on commit 783b300

Please sign in to comment.