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



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/rambulance/exceptions_app.rb', line 31

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



44
45
46
# File 'lib/rambulance/exceptions_app.rb', line 44

def self.local_prefixes
  [Rambulance.view_path]
end

Instance Method Details

#process(action, *args) ⇒ Object



56
57
58
59
60
61
62
63
# File 'lib/rambulance/exceptions_app.rb', line 56

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