diff options
author | Rhenium <rhenium@rhe.jp> | 2014-03-13 18:51:49 +0900 |
---|---|---|
committer | Rhenium <rhenium@rhe.jp> | 2014-03-13 18:51:49 +0900 |
commit | 2cea6a60d9e0e2fc90199084e5e99395e1b02964 (patch) | |
tree | 451459585087da621de963f72283e29863d47995 /app/controllers/errors_controller.rb | |
parent | 7c392ca7735a36948515a392b544ace60a242838 (diff) | |
download | aclog-2cea6a60d9e0e2fc90199084e5e99395e1b02964.tar.gz |
refactor error handling
Diffstat (limited to 'app/controllers/errors_controller.rb')
-rw-r--r-- | app/controllers/errors_controller.rb | 37 |
1 files changed, 0 insertions, 37 deletions
diff --git a/app/controllers/errors_controller.rb b/app/controllers/errors_controller.rb deleted file mode 100644 index f59c6e5..0000000 --- a/app/controllers/errors_controller.rb +++ /dev/null @@ -1,37 +0,0 @@ -class ErrorsController < ApplicationController - before_action :force_format - - def render_error - @exception = env["action_dispatch.exception"] - - case @exception - when Aclog::Exceptions::Forbidden - @status = 403 - @message = t("error.forbidden") - when ActionController::RoutingError, - ActiveRecord::RecordNotFound, - ActionView::MissingTemplate, - Aclog::Exceptions::NotFound - @status = 404 - @message = t("error.not_found") - when OAuth::Unauthorized, - Aclog::Exceptions::Unauthorized - @status = 401 - @message = "" - else - @status = 500 - @message = "#{t("error.internal_error")}: #{@exception.class}" - end - - render status: @status - end - - private - def force_format - request.format = (env["REQUEST_PATH"].scan(/\.([A-Za-z]+)$/).flatten.first || :html).to_sym - - unless request.format == :html || request.format == :json - request.format = :html - end - end -end |