aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/errors_controller.rb
blob: f7087fa0c64663a63f4c02515ed0ffe76322d3f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
class ErrorsController < ApplicationController
  layout "index"

  def render_error
    @exception = env["action_dispatch.exception"]
    @status = ActionDispatch::ExceptionWrapper.new(env, @exception).status_code

    case @exception
    when OAuth::Unauthorized
      # /i/callback
      redirect_to root_path
    when Aclog::Exceptions::TweetNotFound
      render "error", status: 404
    when Aclog::Exceptions::UserNotFound
      render "error", status: 404
    when Aclog::Exceptions::UserNotRegistered
      render "error", status: 404
    when Aclog::Exceptions::UserProtected
      render "error", status: 403
    when Aclog::Exceptions::LoginRequired
      render "error", status: 403
    when ActionController::RoutingError
      render "error", status: 404
    else
      warn @exception
      render "error", status: 500
    end
  end
end