Exception: LHC::Error
- Inherits:
-
StandardError
- Object
- StandardError
- LHC::Error
- Defined in:
- lib/lhc/error.rb
Direct Known Subclasses
ClientError, ParserError, ServerError, Timeout, UnknownError
Instance Attribute Summary collapse
-
#_message ⇒ Object
Returns the value of attribute _message.
-
#response ⇒ Object
Returns the value of attribute response.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(message, response) ⇒ Error
constructor
A new instance of Error.
- #to_s ⇒ Object
Constructor Details
#initialize(message, response) ⇒ Error
Returns a new instance of Error.
54 55 56 57 58 |
# File 'lib/lhc/error.rb', line 54 def initialize(, response) super() self. = self.response = response end |
Instance Attribute Details
#_message ⇒ Object
Returns the value of attribute _message.
4 5 6 |
# File 'lib/lhc/error.rb', line 4 def @_message end |
#response ⇒ Object
Returns the value of attribute response.
4 5 6 |
# File 'lib/lhc/error.rb', line 4 def response @response end |
Class Method Details
.dup ⇒ Object
50 51 52 |
# File 'lib/lhc/error.rb', line 50 def self.dup self end |
.find(response) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/lhc/error.rb', line 42 def self.find(response) return LHC::Timeout if response.timeout? status_code = response.code.to_s[0..2].to_i error = map[status_code] error ||= LHC::UnknownError error end |
.map ⇒ Object
Instance Method Details
#to_s ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/lhc/error.rb', line 60 def to_s return response if response.is_a?(String) request = response.request debug = [] debug << [request.method, request.url].map { |str| fix_invalid_encoding(str) }.join(' ') debug << "Options: #{request.}" debug << "Headers: #{request.headers}" debug << "Response Code: #{response.code} (#{response.[:return_code]})" debug << "Response Options: #{response.}" debug << response.body debug << debug.map { |str| fix_invalid_encoding(str) }.join("\n") end |