Exception: Locd::RequestError
- Inherits:
-
HandledError
- Object
- StandardError
- HandledError
- Locd::RequestError
- Defined in:
- lib/locd/errors.rb
Overview
Base class for HandledError that happen during request processing which should result in useful error responses to the user.
Direct Known Subclasses
Constant Summary collapse
- STATUS_CODE =
400
- STATUS_MESSAGE =
"Bad Request"
Instance Attribute Summary collapse
-
#text ⇒ attr_type
readonly
TODO document
text
attribute.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(text = self.class::STATUS_MESSAGE) ⇒ RequestError
constructor
A new instance of RequestError.
- #to_http_response ⇒ Object
- #to_proxy_machine_cmd ⇒ Object
Constructor Details
#initialize(text = self.class::STATUS_MESSAGE) ⇒ RequestError
Returns a new instance of RequestError.
37 38 39 40 |
# File 'lib/locd/errors.rb', line 37 def initialize text = self.class::STATUS_MESSAGE @text = text super "#{ self.class.status }\n\n#{ text }" end |
Instance Attribute Details
#text ⇒ attr_type (readonly)
TODO document text
attribute.
34 35 36 |
# File 'lib/locd/errors.rb', line 34 def text @text end |
Class Method Details
.status ⇒ Object
25 26 27 |
# File 'lib/locd/errors.rb', line 25 def self.status "#{ self::STATUS_CODE } #{ self::STATUS_MESSAGE }" end |
Instance Method Details
#to_http_response ⇒ Object
42 43 44 |
# File 'lib/locd/errors.rb', line 42 def to_http_response Locd.http_response_for self.class.status, text end |
#to_proxy_machine_cmd ⇒ Object
46 47 48 |
# File 'lib/locd/errors.rb', line 46 def to_proxy_machine_cmd { close: to_http_response } end |