2019-07-10 22:07:39 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
# Gestiona las excepciones que lanzamos desde los controladores
|
|
|
|
module ExceptionHandler
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
class SiteNotFound < StandardError; end
|
2020-08-29 23:21:45 +00:00
|
|
|
class PageNotFound < StandardError; end
|
2019-07-10 22:07:39 +00:00
|
|
|
|
|
|
|
included do
|
|
|
|
rescue_from SiteNotFound, with: :site_not_found
|
2020-08-29 23:21:45 +00:00
|
|
|
rescue_from PageNotFound, with: :page_not_found
|
|
|
|
rescue_from ActionController::RoutingError, with: :page_not_found
|
|
|
|
rescue_from Pundit::NilPolicyError, with: :page_not_found
|
2019-07-10 22:07:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def site_not_found
|
|
|
|
redirect_to sites_path
|
|
|
|
end
|
2020-08-29 23:21:45 +00:00
|
|
|
|
|
|
|
def page_not_found
|
|
|
|
send_file Rails.root.join('public', '404.html')
|
|
|
|
end
|
2019-07-10 22:07:39 +00:00
|
|
|
end
|