Sha256: 6385abf23356f351db5ff140acbab75d6301ce1000bf12efdb00c76544d07b76

Contents?: true

Size: 800 Bytes

Versions: 21

Compression:

Stored size: 800 Bytes

Contents

# frozen_string_literal: true

module NeetoCommonsBackend
  class FailuresController < ApplicationController
    before_action :set_default_format

    def show
      @status_code = params[:status_code] || "404"
      error = @status_code == "404" ?
        t("neeto_commons_backend.error.not_found") :
        t("neeto_commons_backend.error.generic_error")

      if params[:url]
        Rails.logger.warn "ActionController::RoutingError (No route matches [#{request.method}] /#{params[:url]})"
      end

      respond_to do |format|
        format.json { render json: { error: }, status: @status_code }
        format.any { render status: @status_code }
      end
    end

    private

      def set_default_format
        request.format = :html unless request.format == :json
      end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
neeto-commons-backend-1.0.109 app/controllers/neeto_commons_backend/failures_controller.rb
neeto-commons-backend-1.0.108 app/controllers/neeto_commons_backend/failures_controller.rb
neeto-commons-backend-1.0.107 app/controllers/neeto_commons_backend/failures_controller.rb
neeto-commons-backend-1.0.106 app/controllers/neeto_commons_backend/failures_controller.rb
neeto-commons-backend-1.0.105 app/controllers/neeto_commons_backend/failures_controller.rb
neeto-commons-backend-1.0.104 app/controllers/neeto_commons_backend/failures_controller.rb
neeto-commons-backend-1.0.103 app/controllers/neeto_commons_backend/failures_controller.rb
neeto-commons-backend-1.0.102 app/controllers/neeto_commons_backend/failures_controller.rb
neeto-commons-backend-1.0.101 app/controllers/neeto_commons_backend/failures_controller.rb
neeto-commons-backend-1.0.100 app/controllers/neeto_commons_backend/failures_controller.rb
neeto-commons-backend-1.0.99 app/controllers/neeto_commons_backend/failures_controller.rb
neeto-commons-backend-1.0.98 app/controllers/neeto_commons_backend/failures_controller.rb
neeto-commons-backend-1.0.97 app/controllers/neeto_commons_backend/failures_controller.rb
neeto-commons-backend-1.0.96 app/controllers/neeto_commons_backend/failures_controller.rb
neeto-commons-backend-1.0.95 app/controllers/neeto_commons_backend/failures_controller.rb
neeto-commons-backend-1.0.94 app/controllers/neeto_commons_backend/failures_controller.rb
neeto-commons-backend-1.0.93 app/controllers/neeto_commons_backend/failures_controller.rb
neeto-commons-backend-1.0.92 app/controllers/neeto_commons_backend/failures_controller.rb
neeto-commons-backend-1.0.91 app/controllers/neeto_commons_backend/failures_controller.rb
neeto-commons-backend-1.0.90 app/controllers/neeto_commons_backend/failures_controller.rb