From a8f124a7dfd50e7ba6bdb757ec6bba120f8d4189 Mon Sep 17 00:00:00 2001 From: Glenn Sarti Date: Thu, 11 Jul 2019 10:33:30 +0800 Subject: [PATCH] (GH-147) Gracefully fail on LoadError when compiling manifests Previously the sidecar would error completely when a LoadError was encountered. This could be caused by gem Facter trying to load libraries which are not present. StandardError does not trap these. This commit also traps the LoadError and allows the sidecar to return a properly formatted response to Editor Services intead of dumping error text to STDERR. --- lib/puppet-languageserver-sidecar/puppet_parser_helper.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/puppet-languageserver-sidecar/puppet_parser_helper.rb b/lib/puppet-languageserver-sidecar/puppet_parser_helper.rb index d4647075..36f24672 100644 --- a/lib/puppet-languageserver-sidecar/puppet_parser_helper.rb +++ b/lib/puppet-languageserver-sidecar/puppet_parser_helper.rb @@ -21,6 +21,8 @@ def self.compile_node_graph(content) end rescue StandardError => e result.set_error("Error while parsing the file. #{e}") + rescue LoadError => e + result.set_error("Load error while parsing the file. #{e}") end result