Exception: LHC::Error
- Inherits:
-
StandardError
- Object
- StandardError
- LHC::Error
- Includes:
- FixInvalidEncodingConcern
- 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.
57 58 59 60 61 |
# File 'lib/lhc/error.rb', line 57 def initialize(, response) super() self. = self.response = response end |
Instance Attribute Details
#_message ⇒ Object
Returns the value of attribute _message.
6 7 8 |
# File 'lib/lhc/error.rb', line 6 def @_message end |
#response ⇒ Object
Returns the value of attribute response.
6 7 8 |
# File 'lib/lhc/error.rb', line 6 def response @response end |
Class Method Details
.dup ⇒ Object
53 54 55 |
# File 'lib/lhc/error.rb', line 53 def self.dup self end |
.find(response) ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/lhc/error.rb', line 44 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
.to_a ⇒ Object
63 64 65 |
# File 'lib/lhc/error.rb', line 63 def self.to_a [self] end |
Instance Method Details
#to_s ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/lhc/error.rb', line 67 def to_s return response.to_s unless response.is_a?(LHC::Response) request = response.request return unless request.is_a?(LHC::Request) debug = [] debug << [request.method, request.url].map { |str| self.class.fix_invalid_encoding(str) }.join(' ') debug << "Options: #{request.}" debug << "Headers: #{request.scrubbed_headers}" debug << "Response Code: #{response.code} (#{response.[:return_code]})" debug << "Response Options: #{response.}" debug << response.body debug << debug.map { |str| self.class.fix_invalid_encoding(str) }.join("\n") end |