mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-16 18:56:21 +00:00
24 lines
632 B
Ruby
24 lines
632 B
Ruby
# frozen_string_literal: true
|
|
|
|
# Gestiona las excepciones que lanzamos desde los controladores
|
|
module ExceptionHandler
|
|
extend ActiveSupport::Concern
|
|
|
|
class SiteNotFound < StandardError; end
|
|
class PageNotFound < StandardError; end
|
|
|
|
included do
|
|
rescue_from SiteNotFound, with: :site_not_found
|
|
rescue_from PageNotFound, with: :page_not_found
|
|
rescue_from ActionController::RoutingError, with: :page_not_found
|
|
rescue_from Pundit::NilPolicyError, with: :page_not_found
|
|
end
|
|
|
|
def site_not_found
|
|
redirect_to sites_path
|
|
end
|
|
|
|
def page_not_found
|
|
send_file Rails.root.join('public', '404.html')
|
|
end
|
|
end
|