module WillPaginate::Railtie::ShowExceptionsPatch

Extending the exception handler middleware so it properly detects WillPaginate::InvalidPage regardless of it being a tag module.

Public Instance Methods

status_code(exception = @exception)
Also aliased as: status_code_without_paginate
status_code_with_paginate(exception = @exception) click to toggle source
# File lib/will_paginate/railtie.rb, line 39
def status_code_with_paginate(exception = @exception)
  actual_exception = if exception.respond_to?(:cause)
    exception.cause || exception
  elsif exception.respond_to?(:original_exception)
    exception.original_exception
  else
    exception
  end

  if actual_exception.is_a?(WillPaginate::InvalidPage)
    Rack::Utils.status_code(:not_found)
  else
    original_method = method(:status_code_without_paginate)
    if original_method.arity != 0
      original_method.call(exception)
    else
      original_method.call()
    end
  end
end
Also aliased as: status_code
status_code_without_paginate(exception = @exception)
Alias for: status_code