module RestfulError::ActionController

Public Class Methods

included(base) click to toggle source
# File lib/restful_error.rb, line 42
def self.included(base)
  base.rescue_from StandardError do |ex|
    render_exception ex
  end
end

Public Instance Methods

render_exception(ex) click to toggle source
# File lib/restful_error.rb, line 29
def render_exception(ex)
  @exception     = ex.extend(Helper)
  ex.restful.set_env(request.env)
  @status_code   = ex.restful.status_code
  @reason_phrase = ex.restful.reason_phrase
  @message       = ex.restful.message

  raise if @status_code == 500 && Rails.configuration.consider_all_requests_local

  respond_to do |format|
    format.any(:json, :xml, :html){ render 'restful_error/show', status: @status_code }
  end
end