Class: Katello::ErrorsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/katello/errors_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#authorized, #current_organization, #current_organization=, #default_label, #default_label_assigned, #escape_html, #flash_to_headers, #format_time, #generate_label, #label_overridden, #n_gettext_for_generate_label, #no_env_available_msg, #parse_calendar_date, #permission_denied, #render_correct_nav, #section_id

Instance Method Details

#routingObject

handles unknown routes from both / and /api namespaces



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

def routing
  path = params['a']
  ex = HttpErrors::NotFound.new(_("Route does not exist:") + " #{path}")

  if path.match('/api/')
    # custom message which will render in JSON
    logger.error ex.message
    respond_to do |format|
      format.json { render :json => {:displayMessage => ex.message, :errors => [ex.message]}, :status => 404 }
      format.all { render :text => "#{ex.message}", :status => 404 }
    end
  else
    render_404 ex
  end
end