lib/rambulance/exceptions_app.rb in rambulance-0.3.1 vs lib/rambulance/exceptions_app.rb in rambulance-0.4.0
- old
+ new
@@ -19,12 +19,12 @@
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]}"
+ 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
@@ -39,24 +39,34 @@
render(template_exists?(error_path) ? error_path : error_path(:internal_server_error))
end
ACTION
end
+ def process(action, *args)
+ if action.to_s.empty?
+ action = request.env["PATH_INFO"][1..-1].to_sym.tap do |status_in_words|
+ request.env["PATH_INFO"] = "/#{Rack::Utils::SYMBOL_TO_STATUS_CODE[status_in_words]}"
+ end
+ end
+
+ super
+ end
+
private
def process_action(*)
begin
request.GET
rescue BAD_REQUEST_EXCEPTION
- env["MALFORMED_QUERY_STRING"], env["QUERY_STRING"] = env["QUERY_STRING"], ""
+ request.env["MALFORMED_QUERY_STRING"], request.env["QUERY_STRING"] = request.env["QUERY_STRING"], ""
end
super
end
def send_action(name, *args)
- @_status = env["PATH_INFO"][1..-1].to_i
+ @_status = request.env["PATH_INFO"][1..-1].to_i
@_response.status = @_status
@_body = { :status => @_status, :error => Rack::Utils::HTTP_STATUS_CODES.fetch(@_status.to_i, Rack::Utils::HTTP_STATUS_CODES[500]) }
super
end
@@ -64,10 +74,10 @@
def status_in_words
ERROR_HTTP_STATUSES[status.to_i]
end
def exception
- env["action_dispatch.exception"]
+ request.env["action_dispatch.exception"]
end
def error_path(status_in_words = status_in_words())
"#{controller_path}/#{status_in_words}"
end