Module: ExceptionallyBeautiful::ErrorHandler

Included in:
ErrorsController
Defined in:
app/controllers/concerns/exceptionally_beautiful/error_handler.rb

Instance Method Summary collapse

Instance Method Details

#error_handler(status_code) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'app/controllers/concerns/exceptionally_beautiful/error_handler.rb', line 3

def error_handler(status_code)
  @error = ExceptionallyBeautiful::Error.new(status_code)

  respond_to do |format|
    format.html do
      render :template => "#{ExceptionallyBeautiful.controller}/#{ExceptionallyBeautiful.action}",
             :status => @error.status_code,
             :layout => ExceptionallyBeautiful.layout
    end
    format.json { render :json => { :status => @error.status_code, :error => @error.message } }
  end
end