lib/rambulance/exceptions_app.rb in rambulance-0.1.2 vs lib/rambulance/exceptions_app.rb in rambulance-0.2.0

- old
+ new

@@ -21,20 +21,34 @@ end action(status_in_words).call(env) end + def self.local_prefixes + [Rambulance.view_path] + end if ActionPack::VERSION::STRING >= "4.2.0" + ERROR_HTTP_STATUSES.values.each do |status_in_words| eval <<-ACTION def #{status_in_words} render(template_exists?(error_path) ? error_path : error_path(:internal_server_error)) end ACTION end private + def process_action(*) + begin + request.GET + rescue bad_request_exception + env["MALFORMED_QUERY_STRING"], env["QUERY_STRING"] = env["QUERY_STRING"], "" + end + + super + end + def send_action(name, *args) @_status = 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]) } @@ -57,8 +71,14 @@ Rambulance.layout_name end def controller_path Rambulance.view_path + end + + def bad_request_exception + ActionController::BadRequest + rescue NameError + TypeError # Rails 3.2 doesn't know about ActionController::BadRequest end end end