summaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2010-10-23 11:07:04 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2010-10-23 11:07:04 +0000
commit7824eca77561dea52960b3d094389bd4e85eeccf (patch)
treeb19e031644b9d9f67db379b20ff2eae9b08ff8e4 /app/controllers
parenteea456ed84d159289bdc8826439923d365816fa8 (diff)
downloadredmine-7824eca77561dea52960b3d094389bd4e85eeccf.tar.gz
redmine-7824eca77561dea52960b3d094389bd4e85eeccf.zip
Refactor: merged error rendering methods.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4286 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/application_controller.rb42
1 files changed, 17 insertions, 25 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 360d09189..d7b1add85 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -275,39 +275,31 @@ class ApplicationController < ActionController::Base
def render_403(options={})
@project = nil
- @message = options[:message] || :notice_not_authorized
- @message = l(@message) if @message.is_a?(Symbol)
- respond_to do |format|
- format.html { render :template => "common/403", :layout => use_layout, :status => 403 }
- format.atom { head 403 }
- format.xml { head 403 }
- format.js { head 403 }
- format.json { head 403 }
- end
+ render_error({:message => :notice_not_authorized, :status => 403}.merge(options))
return false
end
- def render_404
- respond_to do |format|
- format.html { render :template => "common/404", :layout => use_layout, :status => 404 }
- format.atom { head 404 }
- format.xml { head 404 }
- format.js { head 404 }
- format.json { head 404 }
- end
+ def render_404(options={})
+ render_error({:message => :notice_file_not_found, :status => 404}.merge(options))
return false
end
- def render_error(msg)
+ # Renders an error response
+ def render_error(arg)
+ arg = {:message => arg} unless arg.is_a?(Hash)
+
+ @message = arg[:message]
+ @message = l(@message) if @message.is_a?(Symbol)
+ @status = arg[:status] || 500
+
respond_to do |format|
- format.html {
- flash.now[:error] = msg
- render :text => '', :layout => use_layout, :status => 500
+ format.html {
+ render :template => 'common/error', :layout => use_layout, :status => @status
}
- format.atom { head 500 }
- format.xml { head 500 }
- format.js { head 500 }
- format.json { head 500 }
+ format.atom { head @status }
+ format.xml { head @status }
+ format.js { head @status }
+ format.json { head @status }
end
end