Method: Inspec::Plugin::V2::Loader#exit_on_load_error

Defined in:
lib/inspec/plugin/v2/loader.rb

#exit_on_load_errorObject

This should possibly be in either lib/inspec/cli.rb or Registry



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/inspec/plugin/v2/loader.rb', line 68

def exit_on_load_error
  if registry.any_load_failures?
    Inspec::Log.error "Errors were encountered while loading plugins..."
    registry.plugin_statuses.select(&:load_exception).each do |plugin_status|
      Inspec::Log.error "Plugin name: " + plugin_status.name.to_s
      Inspec::Log.error "Error: " + plugin_status.load_exception.message
      if ARGV.include?("--debug")
        Inspec::Log.error "Exception: " + plugin_status.load_exception.class.name
        Inspec::Log.error "Trace: " + plugin_status.load_exception.backtrace.join("\n")
      end
    end
    Inspec::Log.error("Run again with --debug for a stacktrace.") unless ARGV.include?("--debug")
    exit 2
  end
end