Exception: HTTPStatus::Base

Inherits:
StandardError
  • Object
show all
Defined in:
lib/http_status_exceptions.rb

Constant Summary collapse

@@template_path =
'shared/http_status'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, details = nil) ⇒ Base

Creates the exception with a message and some optional other info.



15
16
17
18
19
# File 'lib/http_status_exceptions.rb', line 15

def initialize(message = nil, details = nil)
  @status = self.class.to_s.split("::").last.underscore.to_sym rescue :internal_server_error
  @details = details
  super(message)
end

Instance Attribute Details

#detailsObject (readonly)

Returns the value of attribute details.



12
13
14
# File 'lib/http_status_exceptions.rb', line 12

def details
  @details
end

#statusObject (readonly)

Returns the value of attribute status.



12
13
14
# File 'lib/http_status_exceptions.rb', line 12

def status
  @status
end

Instance Method Details

#status_codeObject

The numeric status code corresponding to this exception



22
23
24
# File 'lib/http_status_exceptions.rb', line 22

def status_code
  ActionController::StatusCodes::SYMBOL_TO_STATUS_CODE[@status]
end

#templateObject

The name of the template that should be used as error page for this exception



27
28
29
# File 'lib/http_status_exceptions.rb', line 27

def template
  "#{@@template_path}/#{@status}"
end