Exception: Wrangler::HttpStatusError
- Inherits:
-
Exception
- Object
- Exception
- Wrangler::HttpStatusError
- Defined in:
- lib/wrangler/wrangler_exceptions.rb
Overview
base class for all the http-related exception classes
Direct Known Subclasses
HttpForbidden, HttpInternalServerError, HttpNotAcceptable, HttpNotFound, HttpNotImplemented, HttpServiceUnavailable, HttpUnauthorized
Instance Attribute Summary collapse
-
#addl_msg ⇒ Object
readonly
Returns the value of attribute addl_msg.
-
#status_code ⇒ Object
readonly
Returns the value of attribute status_code.
Class Method Summary collapse
-
.status_to_msg(status) ⇒ Object
accepts either a Fixnum status code or a symbol representation of a status code (e.g. 404 or :not_found) yes, this is total duplication of code in action_controller/status_codes.rb, but it’s been made a private instance method in the module.
Instance Method Summary collapse
-
#initialize(status_code, addl_msg = nil) ⇒ HttpStatusError
constructor
A new instance of HttpStatusError.
Constructor Details
#initialize(status_code, addl_msg = nil) ⇒ HttpStatusError
Returns a new instance of HttpStatusError.
7 8 9 10 11 12 13 14 15 |
# File 'lib/wrangler/wrangler_exceptions.rb', line 7 def initialize(status_code, addl_msg = nil) @status_code = status_code @addl_msg = addl_msg = self.class.status_to_msg(status_code) += addl_msg unless addl_msg.nil? super() end |
Instance Attribute Details
#addl_msg ⇒ Object (readonly)
Returns the value of attribute addl_msg.
17 18 19 |
# File 'lib/wrangler/wrangler_exceptions.rb', line 17 def addl_msg @addl_msg end |
#status_code ⇒ Object (readonly)
Returns the value of attribute status_code.
17 18 19 |
# File 'lib/wrangler/wrangler_exceptions.rb', line 17 def status_code @status_code end |
Class Method Details
.status_to_msg(status) ⇒ Object
accepts either a Fixnum status code or a symbol representation of a status code (e.g. 404 or :not_found) yes, this is total duplication of code in action_controller/status_codes.rb, but it’s been made a private instance method in the module.
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/wrangler/wrangler_exceptions.rb', line 25 def self.status_to_msg(status) case status when Fixnum then "#{status} #{ActionController::StatusCodes::STATUS_CODES[status]}".strip when Symbol then status_to_msg(ActionController::StatusCodes::SYMBOL_TO_STATUS_CODE[status] || "500 Unknown Status #{status.inspect}") else status.to_s end end |