Exception: SisRuby::BadResponseError
- Inherits:
-
RuntimeError
- Object
- RuntimeError
- SisRuby::BadResponseError
- Defined in:
- lib/sis_ruby/exceptions/bad_response_error.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
-
#initialize(response) ⇒ BadResponseError
constructor
A new instance of BadResponseError.
- #to_s ⇒ Object
Constructor Details
#initialize(response) ⇒ BadResponseError
Returns a new instance of BadResponseError.
7 8 9 |
# File 'lib/sis_ruby/exceptions/bad_response_error.rb', line 7 def initialize(response) @response = response end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
5 6 7 |
# File 'lib/sis_ruby/exceptions/bad_response_error.rb', line 5 def response @response end |
Instance Method Details
#to_s ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/sis_ruby/exceptions/bad_response_error.rb', line 12 def to_s first_header_line = if response && response.[:response_headers] header_lines = response.[:response_headers].split("\r\n") header_lines.any? ? header_lines.first : nil else nil end body = if response && response.[:response_body] response.[:response_body].rstrip else nil end code = response.code string = "#{self.class.name}: #{code}" string << ": #{body}" if body string << (first_header_line ? " (#{first_header_line})" : '') string end |