Class: RailsExceptionHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_exception_handler.rb,
lib/rails_exception_handler/engine.rb

Defined Under Namespace

Classes: Configuration, Engine, Handler, Parser

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ RailsExceptionHandler

Returns a new instance of RailsExceptionHandler.



3
4
5
# File 'lib/rails_exception_handler.rb', line 3

def initialize(app)
  @app = app
end

Class Method Details

.configurationObject



13
14
15
# File 'lib/rails_exception_handler.rb', line 13

def self.configuration
  @configuration ||= Configuration.new
end

.configure {|configuration| ... } ⇒ Object

Yields:



17
18
19
20
21
22
23
24
25
# File 'lib/rails_exception_handler.rb', line 17

def self.configure
  yield configuration
  return unless configuration.environments.include?(Rails.env.to_sym)

  Rails.configuration.middleware.use(RailsExceptionHandler)

  Rails.configuration.action_dispatch.show_exceptions = true
  require File.expand_path(File.dirname(__FILE__)) + '/patch/show_exceptions.rb'
end

Instance Method Details

#call(env) ⇒ Object



7
8
9
10
11
# File 'lib/rails_exception_handler.rb', line 7

def call(env)
  @app.call(env)
rescue Exception => e
  Handler.new(env, e).handle_exception
end