Exception: HTTPStatus::Base
- Inherits:
-
Exception
- Object
- Exception
- 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.
12 13 14 15 16 |
# File 'lib/http_status_exceptions.rb', line 12 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.
9 10 11 |
# File 'lib/http_status_exceptions.rb', line 9 def details @details end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
9 10 11 |
# File 'lib/http_status_exceptions.rb', line 9 def status @status end |
Instance Method Details
#status_code ⇒ Object
The numeric status code corresponding to this exception
19 20 21 |
# File 'lib/http_status_exceptions.rb', line 19 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
24 25 26 |
# File 'lib/http_status_exceptions.rb', line 24 def template "#{@@template_path}/#{@status}" end |