module Pakyow::Application::Behavior::Rescuing
Lets an app to be rescued from errors encountered during boot. Once rescued, an app returns a 500 response with the error that caused it to fail.
Attributes
rescued[R]
Error
the app was rescued from.
Public Instance Methods
rescued?()
click to toggle source
Returns true if the app has been rescued.
# File lib/pakyow/application/behavior/rescuing.rb, line 20 def rescued? instance_variable_defined?(:@rescued) && !!@rescued end
Private Instance Methods
rescue!(error)
click to toggle source
Enters rescue mode after logging the error.
# File lib/pakyow/application/behavior/rescuing.rb, line 28 def rescue!(error) @rescued = error performing :rescue do Pakyow.logger.error(error) message = <<~ERROR #{self.class} failed to initialize. #{error.message} #{error.backtrace.join("\n")} ERROR # Override call to always return an errored response. # define_singleton_method :call do |connection| connection.status = 500 connection.body = StringIO.new(message) connection.halt end end end