Improved error handling in wiki/save (ticket:153)
This commit is contained in:
parent
7aac9e3690
commit
4053380fd4
3 changed files with 12 additions and 12 deletions
|
@ -107,16 +107,16 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
def rescue_action_in_public(exception)
|
||||
render_text <<-EOL
|
||||
<html>
|
||||
<body>
|
||||
<p>There was a controller specific error processing your request.</p>
|
||||
<!-- \n#{exception}\n#{exception.backtrace.join("\n")}\n -->
|
||||
</body>
|
||||
</html>
|
||||
message = <<-EOL
|
||||
<html><body>
|
||||
<h2>Internal Error 500</h2>
|
||||
<p>An application error occurred while processing your request.</p>
|
||||
<!-- \n#{exception}\n#{exception.backtrace.join("\n")}\n -->
|
||||
</body></html>
|
||||
EOL
|
||||
render_text message, 'Internal Error 500'
|
||||
end
|
||||
|
||||
|
||||
def return_to_last_remembered
|
||||
# Forget the redirect location
|
||||
redirect_target, @session[:return_to] = @session[:return_to], nil
|
||||
|
|
|
@ -190,10 +190,10 @@ class WikiController < ApplicationController
|
|||
)
|
||||
end
|
||||
redirect_to_page @page_name
|
||||
rescue Instiki::ValidationError => e
|
||||
rescue => e
|
||||
page.unlock if defined? page
|
||||
flash[:error] = e
|
||||
return_to_last_remembered
|
||||
redirect_to :action => 'edit', :web => @web_name, :id => @page_name
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -207,7 +207,7 @@ class WikiController < ApplicationController
|
|||
logger.error e
|
||||
flash[:error] = e.message
|
||||
if in_a_web?
|
||||
redirect_to :web => @web_name, :action => 'edit', :id => @page_name
|
||||
redirect_to :action => 'edit', :web => @web_name, :id => @page_name
|
||||
else
|
||||
raise e
|
||||
end
|
||||
|
|
|
@ -556,7 +556,7 @@ class WikiControllerTest < Test::Unit::TestCase
|
|||
'content' => @home.revisions.last.content.dup,
|
||||
'author' => 'SomeOtherAuthor'}, {:return_to => '/wiki1/show/HomePage'}
|
||||
|
||||
assert_redirect_url '/wiki1/show/HomePage'
|
||||
assert_redirected_to :action => 'edit', :web => 'wiki1', :id => 'HomePage'
|
||||
assert_flash_has :error
|
||||
assert r.flash[:error].kind_of?(Instiki::ValidationError)
|
||||
|
||||
|
|
Loading…
Reference in a new issue