Class: Rambulance::ExceptionsApp

Inherits:
ActionController::Base
  • Object
show all
Defined in:
lib/rambulance/exceptions_app.rb

Direct Known Subclasses

ExceptionsApp

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.call(env) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/rambulance/exceptions_app.rb', line 21

def self.call(env)
  exception       = env["action_dispatch.exception"]
  status_in_words = if exception
    ActionDispatch::ExceptionWrapper.rescue_responses[exception.class.to_s]
  else
    env["PATH_INFO"][1..-1].to_sym.tap do |_status_in_words|
      env["PATH_INFO"] = "/#{Rack::Utils::SYMBOL_TO_STATUS_CODE[_status_in_words]}"
    end
  end

  action(status_in_words).call(env)
end

.local_prefixesObject



34
35
36
# File 'lib/rambulance/exceptions_app.rb', line 34

def self.local_prefixes
  [Rambulance.view_path]
end

Instance Method Details

#process(action, *args) ⇒ Object



46
47
48
49
50
51
52
53
# File 'lib/rambulance/exceptions_app.rb', line 46

def process(action, *args)
  if action.to_s.empty?
    action = request.env["PATH_INFO"][1..-1].to_sym
    request.env["PATH_INFO"] = "/#{Rack::Utils::SYMBOL_TO_STATUS_CODE[action]}"
  end

  super
end