lib/fog/azurerm/utilities/general.rb in fog-azure-rm-0.2.7 vs lib/fog/azurerm/utilities/general.rb in fog-azure-rm-0.3.0

- old
+ new

@@ -45,25 +45,28 @@ def get_record_type(type) type.split('/').last end def raise_azure_exception(exception, msg) - message = if exception.respond_to? 'body' - "Exception in #{msg} #{exception.body['error']['message'] unless exception.body['error']['message'].nil?} Type: #{exception.class}\n#{exception.backtrace.join("\n")}" - else - "#{exception.inspect}\n#{exception.backtrace.join("\n")}" - end + if exception.respond_to? 'body' + message = if exception.body['error'].nil? + exception.body['message'] + else + exception.body['error']['message'] + end + exception_message = "Exception in #{msg} #{message} Type: #{exception.class}\n#{exception.backtrace.join("\n")}" + else + "#{exception.inspect}\n#{exception.backtrace.join("\n")}" + end + Fog::Logger.debug exception.backtrace - raise message + raise exception_message end # Make sure if input_params(Hash) contains all keys present in required_params(Array) def validate_params(required_params, input_params) missing_params = required_params.select { |param| param unless input_params.key?(param) } - - if missing_params.any? - raise(ArgumentError, "Missing Parameters: #{missing_params.join(', ')} required for this operation") - end + raise(ArgumentError, "Missing Parameters: #{missing_params.join(', ')} required for this operation") if missing_params.any? end def get_resource_from_resource_id(resource_id, position) data = resource_id.split('/') unless resource_id.nil?