Module: Katello::Api::V2::MultiCVParamsHandling

Extended by:
ActiveSupport::Concern
Includes:
ErrorHandling
Defined in:
app/controllers/katello/concerns/api/v2/multi_cv_params_handling.rb

Instance Method Summary collapse

Instance Method Details

#handle_errors(labels: [], ids: []) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/katello/concerns/api/v2/multi_cv_params_handling.rb', line 7

def handle_errors(labels: [], ids: [])
  if labels.present?
    fail HttpErrors::UnprocessableEntity, "No content view environments found with names: #{labels.join(',')}"
  elsif ids.present?
    fail HttpErrors::UnprocessableEntity, "No content view environments found with ids: #{ids}"
  end
rescue HttpErrors::UnprocessableEntity => e
  respond_for_exception(
    e,
    :status => :unprocessable_entity,
    :text => e.message,
    :errors => [e.message],
    :with_logging => true
  )
end