Skip to content

Commit

Permalink
(GH-51) Add handling of errors when loading classes
Browse files Browse the repository at this point in the history
Previously if there was an error while parsing classes, it would cascade the
error and crash the sidecar.  This commit catches the error and gracefully
continues.
  • Loading branch information
glennsarti committed Oct 2, 2018
1 parent fc334a9 commit 61c728c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/puppet-languageserver-sidecar/puppet_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,12 @@ def self.retrieve_classes(cache, options = {})
classes = PuppetLanguageServer::Sidecar::Protocol::PuppetClassList.new
manifest_path_list.each do |manifest_path|
Dir.glob("#{manifest_path}/**/*.pp").each do |manifest_file|
if path_has_child?(options[:root_path], manifest_file)
classes.concat(load_classes_from_manifest(cache, manifest_file))
begin
if path_has_child?(options[:root_path], manifest_file)
classes.concat(load_classes_from_manifest(cache, manifest_file))
end
rescue StandardError => err
PuppetLanguageServerSidecar.log_message(:error, "[PuppetHelper::retrieve_classes] Error loading manifest #{manifest_file}: #{err} #{err.backtrace}")
end
end
end
Expand Down

0 comments on commit 61c728c

Please sign in to comment.