class SisRuby::BadResponseError

Attributes

response[R]

Public Class Methods

new(response) click to toggle source
# File lib/sis_ruby/exceptions/bad_response_error.rb, line 7
def initialize(response)
  @response = response
end

Public Instance Methods

to_s() click to toggle source
# File lib/sis_ruby/exceptions/bad_response_error.rb, line 12
def to_s

  first_header_line = if response && response.options[:response_headers]
    header_lines = response.options[:response_headers].split("\r\n")
    header_lines.any? ? header_lines.first : nil
  else
    nil
  end

  body = if response && response.options[:response_body]
   response.options[: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