Permalink
Browse files

fix the ExceptionWrapper patch

Closes #215
  • Loading branch information...
1 parent 6f4390b commit e5e6c4729cb41124c44bded73594d380d4700ba2 @mislav committed Jan 31, 2012
Showing with 7 additions and 2 deletions.
  1. +7 −2 lib/will_paginate/railtie.rb
@@ -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

0 comments on commit e5e6c47

Please sign in to comment.