Method: Avm::Gitlab::RestApi::BaseEntity#validate_response_data

Defined in:
lib/avm/gitlab/rest_api/base_entity.rb

#validate_response_data(response, not_found_message = nil) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/avm/gitlab/rest_api/base_entity.rb', line 56

def validate_response_data(response, not_found_message = nil)
  if response.body_data.is_a?(::Hash)
    response.body_data['error'].if_present do |v|
      raise ::RuntimeError, "URL: #{response.url}, Data: #{v}"
    end

    response.body_data['message'].if_present do |v|
      return nil if v == not_found_message
    end
  end

  response.body_data
end