Exception: HTTPStatus::Base
- Inherits:
-
StandardError
- Object
- StandardError
- HTTPStatus::Base
- Defined in:
- lib/http_status_exceptions.rb
Constant Summary collapse
- @@template_path =
'shared/http_status'
Instance Attribute Summary collapse
-
#details ⇒ Object
readonly
Returns the value of attribute details.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(message = nil, details = nil) ⇒ Base
constructor
Creates the exception with a message and some optional other info.
-
#status_code ⇒ Object
The numeric status code corresponding to this exception.
-
#template ⇒ Object
The name of the template that should be used as error page for this exception.
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( = nil, details = nil) @status = self.class.to_s.split("::").last.underscore.to_sym rescue :internal_server_error @details = details super() end |
Instance Attribute Details
#details ⇒ Object (readonly)
Returns the value of attribute details.
12 13 14 |
# File 'lib/http_status_exceptions.rb', line 12 def details @details end |
#status ⇒ Object (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_code ⇒ Object
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 |
#template ⇒ Object
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 |