Skip to content

Commit

Permalink
fix the ExceptionWrapper patch
Browse files Browse the repository at this point in the history
Closes mislav#215
  • Loading branch information
mislav committed Jan 31, 2012
1 parent 6f4390b commit e5e6c47
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/will_paginate/railtie.rb
Expand Up @@ -41,13 +41,18 @@ module ShowExceptionsPatch
extend ActiveSupport::Concern
included { alias_method_chain :status_code, :paginate }
private
def status_code_with_paginate(exception = self.exception)
def status_code_with_paginate(exception = @exception)
if exception.is_a?(WillPaginate::InvalidPage) or
(exception.respond_to?(:original_exception) &&
exception.original_exception.is_a?(WillPaginate::InvalidPage))
Rack::Utils.status_code(:not_found)
else
status_code_without_paginate(exception)
original_method = method(:status_code_without_paginate)
if original_method.arity != 0
original_method.call(exception)
else
original_method.call()
end
end
end
end
Expand Down

0 comments on commit e5e6c47

Please sign in to comment.