class RailsExceptionHandler
Public Class Methods
Source
# File lib/rails_exception_handler/catcher.rb, line 3 def self.catch(&block) begin block.call rescue Exception => exception if(configuration.activate?) exception_handler = Handler.new({'REQUEST_METHOD' => "GET", "rack.input" => ""}, exception) exception_handler.handle_exception else raise exception end end end
Source
# File lib/rails_exception_handler.rb, line 14 def self.configuration @configuration ||= Configuration.new end
Source
# File lib/rails_exception_handler.rb, line 18 def self.configure yield configuration return unless configuration.activate? unless Rails.configuration.middleware.class == ActionDispatch::MiddlewareStack && Rails.configuration.middleware.include?(RailsExceptionHandler) Rails.configuration.middleware.use(RailsExceptionHandler) end Rails.configuration.action_dispatch.show_exceptions = if Rails::VERSION::MAJOR < 7 || (Rails::VERSION::MAJOR == 7 && Rails::VERSION::MINOR == 0) true else :all end Rails.configuration.consider_all_requests_local = false require File.expand_path(File.dirname(__FILE__)) + '/patch/show_exceptions.rb' configuration.run_callback end
Public Instance Methods
Source
# File lib/rails_exception_handler.rb, line 7 def call(env) @app.call(env) rescue Exception => e raise e unless RailsExceptionHandler.configuration.activate? Handler.new(env, e).handle_exception end