Exception: Songkick::Transport::HttpError

Inherits:
UpstreamError
  • Object
show all
Defined in:
lib/songkick/transport/http_error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request, status, headers, body) ⇒ HttpError

Returns a new instance of HttpError.



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/songkick/transport/http_error.rb', line 6

def initialize(request, status, headers, body)
  @request = request

  @data = if body.is_a?(String)
            body.strip == '' ? nil : (Yajl::Parser.parse(body) rescue body)
          else
            body
          end

  @headers = Headers.new(headers)
  @status  = status.to_i
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



4
5
6
# File 'lib/songkick/transport/http_error.rb', line 4

def data
  @data
end

#headersObject (readonly)

Returns the value of attribute headers.



4
5
6
# File 'lib/songkick/transport/http_error.rb', line 4

def headers
  @headers
end

#requestObject (readonly)

Returns the value of attribute request.



4
5
6
# File 'lib/songkick/transport/http_error.rb', line 4

def request
  @request
end

#statusObject (readonly)

Returns the value of attribute status.



4
5
6
# File 'lib/songkick/transport/http_error.rb', line 4

def status
  @status
end

Instance Method Details

#messageObject



19
20
21
# File 'lib/songkick/transport/http_error.rb', line 19

def message
 "#{self.class}: status code: #{@status} from: #{@request}"
end