Exception: DHC::Error
- Inherits:
-
StandardError
- Object
- StandardError
- DHC::Error
- Includes:
- FixInvalidEncodingConcern
- Defined in:
- lib/dhc/error.rb
Direct Known Subclasses
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.
56 57 58 59 60 |
# File 'lib/dhc/error.rb', line 56 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/dhc/error.rb', line 6 def @_message end |
#response ⇒ Object
Returns the value of attribute response.
6 7 8 |
# File 'lib/dhc/error.rb', line 6 def response @response end |
Class Method Details
.dup ⇒ Object
52 53 54 |
# File 'lib/dhc/error.rb', line 52 def self.dup self end |
.find(response) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/dhc/error.rb', line 44 def self.find(response) return DHC::Timeout if response.timeout? status_code = response.code.to_s[0..2].to_i error = map[status_code] error ||= DHC::UnknownError error end |
.map ⇒ Object
.to_a ⇒ Object
62 63 64 |
# File 'lib/dhc/error.rb', line 62 def self.to_a [self] end |
Instance Method Details
#to_s ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/dhc/error.rb', line 66 def to_s return response.to_s unless response.is_a?(DHC::Response) request = response.request return unless request.is_a?(DHC::Request) debug = [] debug << [request.method, request.url].map { |str| self.class.fix_invalid_encoding(str) }.join(' ') debug << "Response Code: #{response.code} (#{response.[:return_code]})" debug << response.body debug << debug.map { |str| self.class.fix_invalid_encoding(str) }.join("\n") end |