Class: ExceptionHandler::Exception

Inherits:
Object
  • Object
show all
Defined in:
app/services/exception_handler/exception.rb

Overview

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request) ⇒ Exception

Returns a new instance of Exception.



7
8
9
10
11
12
13
# File 'app/services/exception_handler/exception.rb', line 7

def initialize request
  @request   = request
  @exception = request.env['action_dispatch.exception']

  @class     = @exception.class
  @message   = @exception.message
end

Instance Attribute Details

#classObject (readonly)

Returns the value of attribute class.



3
4
5
# File 'app/services/exception_handler/exception.rb', line 3

def class
  @class
end

#exceptionObject (readonly)

Returns the value of attribute exception.



3
4
5
# File 'app/services/exception_handler/exception.rb', line 3

def exception
  @exception
end

#messageObject (readonly)

Returns the value of attribute message.



3
4
5
# File 'app/services/exception_handler/exception.rb', line 3

def message
  @message
end

#requestObject (readonly)

Returns the value of attribute request.



3
4
5
# File 'app/services/exception_handler/exception.rb', line 3

def request
  @request
end

Instance Method Details

#codeObject Also known as: status

Status code (404, 500 etc)



18
19
20
# File 'app/services/exception_handler/exception.rb', line 18

def code
  ActionDispatch::ExceptionWrapper.new(@request.env, @exception).status_code
end

#responseObject

Server Response (“Not Found” etc)



23
24
25
# File 'app/services/exception_handler/exception.rb', line 23

def response
  ActionDispatch::ExceptionWrapper.rescue_responses[@exception.class.name]
end