module Errship::Rescuers
Public Class Methods
included(base)
click to toggle source
# File lib/errship.rb, line 16 def self.included(base) unless Rails.application.config.consider_all_requests_local base.rescue_from ActionController::RoutingError, :with => :render_404_error base.rescue_from ActionController::UnknownController, :with => :render_404_error base.rescue_from ActionController::UnknownAction, :with => :render_404_error end end
Public Instance Methods
errship_standard(errship_scope = false)
click to toggle source
A blank page with just the layout and flash message, which can be redirected to when all else fails.
# File lib/errship.rb, line 37 def errship_standard(errship_scope = false) flash[:error] ||= 'An unknown error has occurred, or you have reached this page by mistake.' render :template => '/errship/standard', :locals => { :status_code => 500, :errship_scope => errship_scope } end
flashback(error_message, exception = nil)
click to toggle source
Set the error flash and attempt to redirect back. If RedirectBackError is raised, redirect to error_path instead.
# File lib/errship.rb, line 45 def flashback(error_message, exception = nil) airbrake_class.send(:notify, exception) if airbrake_class flash[:error] = error_message begin redirect_to :back rescue ActionController::RedirectBackError redirect_to error_path end end
render_404_error(exception = nil, errship_scope = false)
click to toggle source
# File lib/errship.rb, line 30 def render_404_error(exception = nil, errship_scope = false) render :template => '/errship/standard', :locals => { :status_code => 404, :errship_scope => errship_scope }, :status => (Errship.status_code_success ? 200 : 404) end
render_error(exception, errship_scope = false)
click to toggle source
# File lib/errship.rb, line 24 def render_error(exception, errship_scope = false) airbrake_class.send(:notify, exception) if airbrake_class render :template => '/errship/standard', :locals => { :status_code => 500, :errship_scope => errship_scope }, :status => (Errship.status_code_success ? 200 : 500) end
Private Instance Methods
airbrake_class()
click to toggle source
# File lib/errship.rb, line 56 def airbrake_class return Airbrake if defined?(Airbrake) return HoptoadNotifier if defined?(HoptoadNotifier) return false end