Class: RestfulError::ExceptionsController

Inherits:
ActionController::Metal
  • Object
show all
Includes:
AbstractController::Rendering, ActionView::Layouts
Defined in:
lib/restful_error/railtie.rb

Instance Method Summary collapse

Instance Method Details

#showObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/restful_error/railtie.rb', line 11

def show
  @exception = request.env["action_dispatch.exception"]
  status = Status.new(request.path_info[1..].to_i)
  @status_code = status.code
  @reason_phrase = status.reason_phrase
  @message = @exception.try(:response_message)
  unless @message
    class_name = @exception.class.name
    class_key = RestfulError::Inflector.underscore(class_name)
    @message = I18n.t class_key, default: [ status.symbol, @reason_phrase ], scope: :restful_error
  end

  self.status = status.code
  render "restful_error/show"
end