Skip to content

Commit

Permalink
Output error backtrace (#318)
Browse files Browse the repository at this point in the history
* Output error backtrace

Signed-off-by: Omer Demirok <odemirok@chef.io>

* Inclute error message

Signed-off-by: Omer Demirok <odemirok@chef.io>

* Include error message

Signed-off-by: Omer Demirok <odemirok@chef.io>
  • Loading branch information
Omer Demirok authored Oct 21, 2020
1 parent 6e462c8 commit 65dbd21
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion libraries/azure_backend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ def initialize(opts = {})
resource_fail(message)
raise StandardError, message
end

# We can't raise an error due to `InSpec check` builds up a dummy backend and any error at this stage fails it.
unless @azure.credentials.values.compact.delete_if(&:empty?).size == 4
Inspec::Log.error 'The following must be set in the Environment:'\
" #{@azure.credentials.keys}.\n"\
"Missing: #{@azure.credentials.keys.select { |key| @azure.credentials[key].nil? }}"
end
end

private
Expand Down Expand Up @@ -447,7 +454,7 @@ def catch_failed_resource_queries
message = "Unable to get information from the REST API for #{@__resource_name__}: #{@display_name}.\n#{e.message}"
resource_fail(message)
rescue StandardError => e
message = "Resource is failed due to #{e}"
message = "Resource is failed due to #{e}. Error backtrace:#{e.backtrace.join(' ')}"
resource_fail(message)
end

Expand Down
2 changes: 1 addition & 1 deletion test/unit/resources/helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'minitest/autorun'
require 'minitest/unit'
require 'minitest/pride'
require 'inspec/resource'
require 'inspec'

0 comments on commit 65dbd21

Please sign in to comment.