Skip to content

Instantly share code, notes, and snippets.

@tkawa
Created August 28, 2013 16:06
Show Gist options
  • Save tkawa/6367801 to your computer and use it in GitHub Desktop.
Save tkawa/6367801 to your computer and use it in GitHub Desktop.
class ErrorsEngine < Rails::Engine
routes.draw do
Site.all.each do |site|
match '(errors)/:status', via: [:get, :post, :put, :patch, :delete], to: 'errors#show', constraints: { host: site.hostname, status: /\d{3}/ }
end
end
end
unless Rails.application.config.consider_all_requests_local
Rails.application.config.exceptions_app = ErrorsEngine.routes
end
Rails.application.config.action_dispatch.rescue_responses.merge!(
'Site::ConnectionError' => :service_unavailable,
'Site::RecordNotFound' => :not_found
)
ActionDispatch::ExceptionWrapper.rescue_responses.merge!(Rails.application.config.action_dispatch.rescue_responses)
@mori-dev
Copy link

👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment