Module: Errship::Rescuers
- Defined in:
- lib/errship.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#errship_standard(errship_scope = false) ⇒ Object
A blank page with just the layout and flash message, which can be redirected to when all else fails.
-
#flashback(error_message, exception = nil) ⇒ Object
Set the error flash and attempt to redirect back.
- #render_404_error(exception = nil, errship_scope = false) ⇒ Object
- #render_error(exception, errship_scope = false) ⇒ Object
Class Method Details
.included(base) ⇒ Object
16 17 18 19 20 21 22 |
# 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 |
Instance Method Details
#errship_standard(errship_scope = false) ⇒ Object
A blank page with just the layout and flash message, which can be redirected to when all else fails.
37 38 39 40 41 |
# 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) ⇒ Object
Set the error flash and attempt to redirect back. If RedirectBackError is raised, redirect to error_path instead.
45 46 47 48 49 50 51 52 53 |
# File 'lib/errship.rb', line 45 def flashback(, exception = nil) airbrake_class.send(:notify, exception) if airbrake_class flash[:error] = begin redirect_to :back rescue ActionController::RedirectBackError redirect_to error_path end end |
#render_404_error(exception = nil, errship_scope = false) ⇒ Object
30 31 32 33 |
# 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) ⇒ Object
24 25 26 27 28 |
# 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 |