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,14 +107,14 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def rescue_action_in_public(exception)
|
def rescue_action_in_public(exception)
|
||||||
render_text <<-EOL
|
message = <<-EOL
|
||||||
<html>
|
<html><body>
|
||||||
<body>
|
<h2>Internal Error 500</h2>
|
||||||
<p>There was a controller specific error processing your request.</p>
|
<p>An application error occurred while processing your request.</p>
|
||||||
<!-- \n#{exception}\n#{exception.backtrace.join("\n")}\n -->
|
<!-- \n#{exception}\n#{exception.backtrace.join("\n")}\n -->
|
||||||
</body>
|
</body></html>
|
||||||
</html>
|
|
||||||
EOL
|
EOL
|
||||||
|
render_text message, 'Internal Error 500'
|
||||||
end
|
end
|
||||||
|
|
||||||
def return_to_last_remembered
|
def return_to_last_remembered
|
||||||
|
|
|
@ -190,10 +190,10 @@ class WikiController < ApplicationController
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
redirect_to_page @page_name
|
redirect_to_page @page_name
|
||||||
rescue Instiki::ValidationError => e
|
rescue => e
|
||||||
page.unlock if defined? page
|
page.unlock if defined? page
|
||||||
flash[:error] = e
|
flash[:error] = e
|
||||||
return_to_last_remembered
|
redirect_to :action => 'edit', :web => @web_name, :id => @page_name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -207,7 +207,7 @@ class WikiController < ApplicationController
|
||||||
logger.error e
|
logger.error e
|
||||||
flash[:error] = e.message
|
flash[:error] = e.message
|
||||||
if in_a_web?
|
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
|
else
|
||||||
raise e
|
raise e
|
||||||
end
|
end
|
||||||
|
|
|
@ -556,7 +556,7 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||||
'content' => @home.revisions.last.content.dup,
|
'content' => @home.revisions.last.content.dup,
|
||||||
'author' => 'SomeOtherAuthor'}, {:return_to => '/wiki1/show/HomePage'}
|
'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_flash_has :error
|
||||||
assert r.flash[:error].kind_of?(Instiki::ValidationError)
|
assert r.flash[:error].kind_of?(Instiki::ValidationError)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue